3 err
() { printf '%b\n' "$*" 1>&2; exit 1; }
4 vr
() { echo "$@"; "$@"; }
19 acmd
=$
(git config
--get "alias.${cmd}" |
sed 's: -.*::')
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/}
121 while [[ $# -gt 0 ]] ; do
128 err
"unknown option: $1"
135 if [[ -n ${reviewers} ]] ; then
136 reviewers
=( ${reviewers//,/ } )
137 git_args
+=( "--receive-pack=git receive-pack ${reviewers[*]/#/--reviewer=}" )
140 for remote
in cros-internal cros origin
; do
141 if g cfg
--get "remote.${remote}.url" >/dev
/null
; then
142 vr git push
"${git_args[@]}" ${remote} ${branch}:refs/for/${remote_branch}
146 err "could not figure out remote to push to
"
149 [[ $# -eq 0 ]] && set -- -j16
153 while [[ $# -gt 0 ]] ; do
156 if [[ $2 == *"OWNERS
" ]] ; then
157 owners=$(awk -F'@' '{list = list "," $1} END {print substr(list, 2)}' "$2")
158 if [[ -z ${owners} ]] ; then
159 err "cannot
find OWNERS list
"
161 echo "Auto setting reviewers to
: ${owners}"
163 args+=( --re "${owners}" )
176 exec repo ${acmd:-${cmd}} "$@
"