3 err
() { printf '%b\n' "$*" 1>&2; exit 1; }
4 vr
() { echo "$@"; "$@"; }
19 acmd
=$
(git config
--get "alias.${cmd}")
23 case ${acmd:-${cmd}} in
25 if [[ $1 == "all" ]] ; then
27 if [[ $# -eq 0 ]] ; then
28 exec r forall
-p -c 'r rb all .' </dev
/null
31 branches
=$
(g b |
awk '
33 if ($0 ~ "^[*] *[(]no branch[)]") {
35 } else if ($1 == "*") {
41 END { print list b }')
42 [[ -z ${branches} ]] && exit 0
44 eval $
(bash-colors
--env)
45 #echo "${GOOD}### ${PWD}${NORMAL}"
46 for b
in ${branches} ; do
47 echo " ${HILITE}### $b${NORMAL}"
60 while [[ ! -d ${root}/.repo
&& ${root} != "/" ]] ; do
63 cd "${root}" ||
exit 1
65 if [[ ! -e .repo
/sandbox-url
]] ; then
66 err
"Please configure remote url base in ${root}/.repo/sandbox-url"
68 remote
=$
(<.repo
/sandbox-url
) ||
exit 1
70 echo "pushing projects from ${root}"
75 exec {ctlfd
}<>"${pipe}"
80 tcnt
=$
(echo "${rlist}" |
wc -l)
85 export GIT_DIR
=${path}/.git
87 printf '### (%*i/%i %3i%%) %s\n' \
88 ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
90 g l
-1 ${src} >& /dev
/null || src
=
92 g push
--force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev
/null
93 echo ${BASHPID} $?
>&${ctlfd}
96 # ssh servers do not like it when you hammer them :)
97 # Received disconnect from 74.125.248.80: 7: Too many concurrent connections
98 # fatal: The remote end hung up unexpectedly
100 if [[ ${jobs} -eq 16 ]] ; then
101 read -r -u ${ctlfd} pid ret
110 # For the times when repo is being stupid, push directly to gerrit myself.
111 if ! branch
=$
(g symbolic-ref
-q HEAD
) ; then
112 err
"could not figure out active branch"
114 branch
=${branch#refs/heads/}
115 if ! remote_branch
=$
(g cfg
--get "branch.${branch}.merge") ; then
116 err
"could not figure out remote branch"
118 remote_branch
=${remote_branch#refs/heads/}
120 for remote
in cros-internal cros origin
; do
121 if g cfg
--get "remote.${remote}.url" >/dev
/null
; then
122 vr git push
${remote} ${branch}:refs/for/${remote_branch}
126 err
"could not figure out remote to push to"
129 [[ $# -eq 0 ]] && set -- -j16
133 while [[ $# -gt 0 ]] ; do
136 if [[ $2 == *"OWNERS" ]] ; then
137 owners
=$
(awk -F'@' '{list = list "," $1} END {print substr(list, 2)}' "$2")
138 if [[ -z ${owners} ]] ; then
139 err
"cannot find OWNERS list"
141 echo "Auto setting reviewers to: ${owners}"
143 args
+=( --re "${owners}" )
156 exec repo
${acmd:-${cmd}} "$@"