]>
Commit | Line | Data |
---|---|---|
35c220c5 MF |
1 | #!/bin/bash |
2 | g() { git "$@"; } | |
955eb9e8 | 3 | |
765bb138 MF |
4 | case $1 in |
5 | ""|-*) ;; | |
6 | *) | |
7 | cmd=$1 | |
8 | shift | |
9 | acmd=$(git config --get "alias.${cmd}") | |
10 | ;; | |
11 | esac | |
35c220c5 | 12 | |
955eb9e8 | 13 | case ${acmd:-${cmd}} in |
35c220c5 MF |
14 | rebase) |
15 | if [[ $1 == "all" ]] ; then | |
e947e1df | 16 | shift |
e051dd74 MF |
17 | if [[ $# -eq 0 ]] ; then |
18 | exec r forall -c 'r rb all .' | |
19 | fi | |
20 | ||
e947e1df MF |
21 | branches=$(g b | awk ' |
22 | { | |
23 | if ($0 ~ "^[*] *[(]no branch[)]") { | |
24 | next | |
25 | } else if ($1 == "*") { | |
26 | b = $NF | |
27 | } else { | |
28 | list = list $NF " " | |
29 | } | |
30 | } | |
31 | END { print list b }') | |
e051dd74 MF |
32 | [[ -z ${branches} ]] && exit 0 |
33 | ||
34 | eval $(bash-colors --env) | |
35 | echo "${GOOD}### ${PWD}${NORMAL}" | |
e947e1df | 36 | for b in ${branches} ; do |
e051dd74 | 37 | echo " ${HILITE}### $b${NORMAL}" |
35c220c5 | 38 | g co $b || exit 1 |
e051dd74 MF |
39 | if ! r rb "$@" ; then |
40 | g rb-a | |
41 | fi | |
35c220c5 MF |
42 | done |
43 | exit 0 | |
44 | fi | |
45 | ;; | |
955eb9e8 MF |
46 | sb-push) |
47 | sync_branch="v" | |
48 | ||
49 | root=${PWD} | |
50 | while [[ ! -d ${root}/.repo && ${root} != "/" ]] ; do | |
51 | root=${root%/*} | |
52 | done | |
53 | cd "${root}" || exit 1 | |
54 | ||
55 | if [[ ! -e .repo/sandbox-url ]] ; then | |
56 | echo "Please configure remote url base in ${root}/.repo/sandbox-url" | |
57 | exit 1 | |
58 | fi | |
59 | remote=$(<.repo/sandbox-url) || exit 1 | |
60 | ||
61 | echo "pushing projects from ${root}" | |
62 | ||
63 | pids=() | |
64 | rlist=$(r list) | |
65 | tcnt=$(echo "${rlist}" | wc -l) | |
66 | cnt=1 | |
67 | while read line ; do | |
68 | line=( ${line} ) | |
69 | path=${line[0]} | |
70 | export GIT_DIR=${path}/.git | |
71 | proj=${line[2]} | |
72 | printf '### (%*i/%i %3i%%) %s\n' \ | |
73 | ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj} | |
74 | src="${sync_branch}" | |
75 | g l -1 ${src} >& /dev/null || src= | |
76 | ( g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null ) & | |
77 | ||
78 | # ssh servers do not like it when you hammer them :) | |
79 | # Received disconnect from 74.125.248.80: 7: Too many concurrent connections | |
80 | # fatal: The remote end hung up unexpectedly | |
81 | pids+=( $! ) | |
82 | if [[ ${#pids[@]} -eq 20 ]] ; then | |
83 | wait ${pids[@]:0:3} | |
84 | pids=( ${pids[@]:3} ) | |
85 | fi | |
86 | done <<<"$(r list)" | |
87 | wait | |
88 | ||
89 | exit 0 | |
90 | ;; | |
35c220c5 MF |
91 | esac |
92 | ||
93 | exec repo ${acmd:-${cmd}} "$@" |