From 003d4f70e9c551deb856cdbcc6e80dadcefa257a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 16 Sep 2013 15:23:52 -0400 Subject: [PATCH] r: add OWNERS parsing to all upload commands --- .bin/r | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/.bin/r b/.bin/r index 6a86466..003121a 100755 --- a/.bin/r +++ b/.bin/r @@ -56,6 +56,28 @@ repo_root() { echo "${root}" } +process_reviewers() { + local r arr=() + for r in ${*//,/ } ; do + case ${r} in + *OWNERS) + local owners=$(awk -F'@' '{list = list "," $1} END {print substr(list, 2)}' "${r}") + if [[ -z ${owners} ]] ; then + err "cannot find OWNERS list" + else + echo "Auto setting reviewers to: ${owners}" + fi + arr+=( ${owners} ) + ;; + *) + arr+=( "${r}" ) + ;; + esac + done + reviewers=$(printf '%s,' "${arr[@]}") + reviewers=${reviewers%,} +} + case ${acmd:-${cmd}} in rebase) if [[ $1 == "all" ]] ; then @@ -202,7 +224,7 @@ g-push) while [[ $# -gt 0 ]] ; do case $1 in --re) - reviewers=$2 + process_reviewers "$2" shift ;; -n|--dry-run|--draft) @@ -237,17 +259,10 @@ upload) while [[ $# -gt 0 ]] ; do case $1 in --re) - if [[ $2 == *"OWNERS" ]] ; then - owners=$(awk -F'@' '{list = list "," $1} END {print substr(list, 2)}' "$2") - if [[ -z ${owners} ]] ; then - err "cannot find OWNERS list" - else - echo "Auto setting reviewers to: ${owners}" - fi - args+=( --re "${owners}" ) - shift 2 - continue - fi + process_reviewers "$2" + args+=( --re "${reviewers}" ) + shift 2 + continue ;; esac args+=( "$1" ) -- 2.39.5