]> git.wh0rd.org Git - home.git/commitdiff
support pushing to user sandbox
authorMike Frysinger <vapier@gentoo.org>
Tue, 6 Mar 2012 21:12:42 +0000 (16:12 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Apr 2012 19:36:44 +0000 (15:36 -0400)
.bin/r

diff --git a/.bin/r b/.bin/r
index 80f2354d97281b523ae0021449bc706f1b70aca1..0f5e8f24bb2cde2b2a25efaf7bfb5449a467c431 100755 (executable)
--- a/.bin/r
+++ b/.bin/r
@@ -1,10 +1,11 @@
 #!/bin/bash
 g() { git "$@"; }
+
 cmd=$1
 shift
-acmd=$(git config --get "alias.${cmd}")
+[[ -n ${cmd} ]] && acmd=$(git config --get "alias.${cmd}")
 
-case ${acmd} in
+case ${acmd:-${cmd}} in
 rebase)
        if [[ $1 == "all" ]] ; then
                shift
@@ -27,6 +28,51 @@ rebase)
                exit 0
        fi
        ;;
+sb-push)
+       sync_branch="v"
+
+       root=${PWD}
+       while [[ ! -d ${root}/.repo && ${root} != "/" ]] ; do
+               root=${root%/*}
+       done
+       cd "${root}" || exit 1
+
+       if [[ ! -e .repo/sandbox-url ]] ; then
+               echo "Please configure remote url base in ${root}/.repo/sandbox-url"
+               exit 1
+       fi
+       remote=$(<.repo/sandbox-url) || exit 1
+
+       echo "pushing projects from ${root}"
+
+       pids=()
+       rlist=$(r list)
+       tcnt=$(echo "${rlist}" | wc -l)
+       cnt=1
+       while read line ; do
+               line=( ${line} )
+               path=${line[0]}
+               export GIT_DIR=${path}/.git
+               proj=${line[2]}
+               printf '### (%*i/%i %3i%%) %s\n' \
+                       ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
+               src="${sync_branch}"
+               g l -1 ${src} >& /dev/null || src=
+               ( g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null ) &
+
+               # ssh servers do not like it when you hammer them :)
+               #       Received disconnect from 74.125.248.80: 7: Too many concurrent connections
+               #       fatal: The remote end hung up unexpectedly
+               pids+=( $! )
+               if [[ ${#pids[@]} -eq 20 ]] ; then
+                       wait ${pids[@]:0:3}
+                       pids=( ${pids[@]:3} )
+               fi
+       done <<<"$(r list)"
+       wait
+
+       exit 0
+       ;;
 esac
 
 exec repo ${acmd:-${cmd}} "$@"