3 err
() { printf '%b\n' "$*" 1>&2; exit 1; }
4 vr
() { echo "$@"; "$@"; }
19 acmd
=$
(git config
--get "alias.${cmd}" |
sed 's: -.*::')
27 exec {ctlfd
}<>"${pipe}"
30 jobs_max
=${1:-$(getconf _NPROCESSORS_ONLN)}
32 _mj_child
() { echo ${BASHPID} $? >&${ctlfd} ; }
42 if [[ ${jobs} -eq ${jobs_max} ]] ; then
43 read -r -u ${ctlfd} pid ret
53 while [[ ! -d ${root}/.repo
&& ${root} != "/" ]] ; do
59 case ${acmd:-${cmd}} in
61 if [[ $1 == "all" ]] ; then
63 if [[ $# -eq 0 ]] ; then
66 while read -a line
; do
71 out
=$
(r rb all .
2>&1)
72 [[ -n ${out} ]] && echo "${out}"
79 #exec r forall -p -c 'r rb all .' </dev/null
82 branches
=$
(g b |
awk '
84 if ($0 ~ "^[*] *[(]no branch[)]") {
86 } else if ($1 == "*") {
92 END { print list b }')
93 [[ -z ${branches} ]] && exit 0
95 eval $
(bash-colors
--env)
96 #echo "${GOOD}### ${PWD}${NORMAL}"
97 for b
in ${branches} ; do
98 #echo " ${HILITE}### $b${NORMAL}"
100 if ! r rb
-q "$@" ; then
111 cd "${root}" ||
exit 1
113 if [[ ! -e .repo
/sandbox-url
]] ; then
114 err
"Please configure remote url base in ${root}/.repo/sandbox-url"
116 remote
=$
(<.repo
/sandbox-url
) ||
exit 1
118 echo "pushing projects from ${root}"
120 # ssh servers do not like it when you hammer them :)
121 # Received disconnect from 74.125.248.80: 7: Too many concurrent connections
122 # fatal: The remote end hung up unexpectedly
126 tcnt
=$
(echo "${rlist}" |
wc -l)
131 export GIT_DIR
=${path}/.git
133 printf '### (%*i/%i %3i%%) %s\n' \
134 ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
136 g l
-1 ${src} >& /dev
/null || src
=
137 mj_child g push
--force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev
/null
144 # For the times when repo is being stupid, push directly to gerrit myself.
145 if ! branch
=$
(g symbolic-ref
-q HEAD
) ; then
146 err
"could not figure out active branch"
148 branch
=${branch#refs/heads/}
149 if ! remote_branch
=$
(g cfg
--get "branch.${branch}.merge") ; then
150 err
"could not figure out remote branch"
152 remote_branch
=${remote_branch#refs/heads/}
155 while [[ $# -gt 0 ]] ; do
162 err
"unknown option: $1"
169 if [[ -n ${reviewers} ]] ; then
170 reviewers
=( ${reviewers//,/ } )
171 git_args
+=( "--receive-pack=git receive-pack ${reviewers[*]/#/--reviewer=}" )
174 for remote
in cros-internal cros origin
; do
175 if g cfg
--get "remote.${remote}.url" >/dev
/null
; then
176 vr git push
"${git_args[@]}" ${remote} ${branch}:refs/for/${remote_branch}
180 err "could not figure out remote to push to
"
187 while [[ $# -gt 0 ]] ; do
190 if [[ $2 == *"OWNERS
" ]] ; then
191 owners=$(awk -F'@' '{list = list "," $1} END {print substr(list, 2)}' "$2")
192 if [[ -z ${owners} ]] ; then
193 err "cannot
find OWNERS list
"
195 echo "Auto setting reviewers to
: ${owners}"
197 args+=( --re "${owners}" )
210 exec repo ${acmd:-${cmd}} "$@
"