]> git.wh0rd.org Git - home.git/commitdiff
r: add OWNERS parsing to all upload commands
authorMike Frysinger <vapier@gentoo.org>
Mon, 16 Sep 2013 19:23:52 +0000 (15:23 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 16 Sep 2013 19:23:52 +0000 (15:23 -0400)
.bin/r

diff --git a/.bin/r b/.bin/r
index 6a86466c38ecdedb3e53527b7699c15e4699ac62..003121a4edd3fc6aaa2d45d6a7b2eec9df69ba67 100755 (executable)
--- 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" )