]> git.wh0rd.org - home.git/blobdiff - .bin/r
r: call rb-all directly to avoid double expansion
[home.git] / .bin / r
diff --git a/.bin/r b/.bin/r
index 24fc5e4090645fdbb32d926cbfecef8fa8544e90..83816bd0bc68f54c698d89e1d77d0162f39a5397 100755 (executable)
--- a/.bin/r
+++ b/.bin/r
@@ -8,19 +8,10 @@ case $1 in
 esac
 
 case $1 in
-""|-*) ;;
-l)
-       cmd=list
+rb-all)
+       cmd=rebase
        shift
-       ;;
-s)
-       cmd=sync
-       shift
-       ;;
-*)
-       cmd=$1
-       shift
-       acmd=$(git config --get "alias.${cmd}" | sed 's: -.*::')
+       set -- all "$@"
        ;;
 esac
 
@@ -54,7 +45,7 @@ mj_finish() {
 
 repo_root() {
        local root=${PWD}
-       while [[ ! -d ${root}/.repo && ${root} != "/" ]] ; do
+       while [[ ! -d ${root}/.repo && ${root:-/} != "/" ]] ; do
                root=${root%/*}
        done
        echo "${root}"
@@ -64,7 +55,7 @@ process_reviewers() {
        local r arr=()
        for r in ${*//,/ } ; do
                case ${r} in
-               *OWNERS)
+               OWNERS*|*/OWNERS*)
                        local owners=$(
                                awk -F'@' '
                                        ($2 == "chromium.org" || $2 == "google.com") {list = list "," $1}
@@ -132,7 +123,7 @@ rebase)
        if [[ $1 == "all" ]] ; then
                shift
                if [[ $# -eq 0 ]] ; then
-                       eval $(bash-colors --env | sed 's:^:export :')
+                       eval "$(bash-colors --env | sed 's:^:export :')"
                        root=$(repo_root)
                        mj_init
                        while read -a line ; do
@@ -143,18 +134,10 @@ rebase)
                                        continue
                                fi
                                (
-                               out=$(env _proj=${proj} r rb all . 2>&1)
+                               out=$(r rb-all . 2>&1)
                                if [[ -n ${out} ]] ; then
-                                       while read line ; do
-                                               if [[ ${line} == "# "* ]] ; then
-                                                       line="${line#[#] }"
-                                                       printf '%s### %s%-40s%s: %s\n' \
-                                                               "${BRACKET}" "${GOOD}" "${line%%:*}" "${NORMAL}" "${line#*:}"
-                                               else
-                                                       printf '%s### %s%-40s%s: ERROR: %s\n' \
-                                                               "${BRACKET}" "${BAD}" "${dir}" "${NORMAL}" "${line}"
-                                               fi
-                                       done < <(echo "${out}")
+                                       head=$(printf "%-40s" "${proj}")
+                                       echo "${out}" | sed "s:^:${head} :"
                                fi
                                _mj_child
                                ) &
@@ -165,36 +148,7 @@ rebase)
                        #exec r forall -p -c 'r rb all .' </dev/null
                fi
 
-               branches=$(g b | awk '
-                       {
-                               if ($0 ~ "^[*] *[(]no branch[)]") {
-                                       next
-                               } else if ($0 ~ "^[*] *[(](HEAD )?detached (from|at) ") {
-                                       next
-                               } else if ($1 == "*") {
-                                       b = $2
-                               } else {
-                                       list = list $1 " "
-                               }
-                       }
-                       END { print list b }')
-               [[ -z ${branches} ]] && exit 0
-
-               [[ -z ${GOOD} ]] && eval $(bash-colors --env)
-               #echo "${GOOD}### ${PWD}${NORMAL}"
-               # Skip if rebase is in progress.
-               if [[ -e .git/rebase-merge/interactive ]] ; then
-                       echo -e "# ${_proj}: ${WARN}skipping due to active rebase${NORMAL}"
-                       exit 1
-               fi
-               for b in ${branches} ; do
-                       #echo " ${HILITE}### $b${NORMAL}"
-                       g co -q $b || exit 1
-                       if ! r rb -q "$@" ; then
-                               g rb-a
-                       fi
-               done
-               exit 0
+               exec git rb-all -q
        fi
        ;;
 clean)
@@ -271,59 +225,6 @@ sb)
 
        exit 0
        ;;
-g-push)
-       # For the times when repo is being stupid, push directly to gerrit myself.
-       if ! branch=$(g symbolic-ref -q HEAD) ; then
-               err "could not figure out active branch"
-       fi
-       branch=${branch#refs/heads/}
-       if ! remote_branch=$(g cfg --get "branch.${branch}.merge") ; then
-               echo "could not figure out remote branch; using ${branch}"
-               remote_branch=${branch}
-       fi
-       if ! remote=$(g cfg --get "branch.${branch}.remote") ; then
-               for remote in cros-internal cros origin ; do
-                        g cfg --get "remote.${remote}.url" >/dev/null && break
-               done
-       fi
-       review=$(g cfg --get "remote.${remote}.review")
-       remote_branch=${remote_branch#refs/heads/}
-
-       git_args=()
-       reviewers=""
-       while [[ $# -gt 0 ]] ; do
-               case $1 in
-               --re)
-                       process_reviewers "$2"
-                       shift
-                       ;;
-               -n|--dry-run|--draft)
-                       git_args+=( $1 )
-                       ;;
-               *)
-                       err "unknown option: $1"
-                       ;;
-               esac
-               shift
-       done
-
-       ref_spec="${branch}:refs/for/${remote_branch}"
-       if [[ -n ${reviewers} ]] ; then
-               reviewers=( ${reviewers//,/ } )
-               if [[ ${review} != ssh://* ]] ; then
-                       gob_args=$(printf 'r=%s,' "${reviewers[@]}")
-                       ref_spec+="%${gob_args%,}"
-               else
-                       git_args+=( "--receive-pack=git receive-pack ${reviewers[*]/#/--reviewer=}" )
-               fi
-       fi
-
-       vr git push "${git_args[@]}" ${remote} ${ref_spec} && exit
-       err "could not figure out remote to push to"
-       ;;
-sync)
-       set -- -j16 -c "$@"
-       ;;
 upload)
        args=()
        while [[ $# -gt 0 ]] ; do
@@ -352,4 +253,4 @@ email)
        ;;
 esac
 
-exec python2 $(find_repo) ${acmd:-${cmd}} "$@"
+exec $(find_repo) ${acmd:-${cmd}} "$@"