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