From 955eb9e88424ad16c3c3f1c0dd51ce3ec1d4a890 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 6 Mar 2012 16:12:42 -0500 Subject: [PATCH] support pushing to user sandbox --- .bin/r | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/.bin/r b/.bin/r index 80f2354..0f5e8f2 100755 --- 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}} "$@" -- 2.39.5