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
64 eval $
(bash-colors
--env |
sed 's:^:export :')
67 while read -a line
; do
72 out
=$
(env _proj
=${proj} r rb all .
2>&1)
73 if [[ -n ${out} ]] ; then
75 if [[ ${line} == "# "* ]] ; then
77 printf '%s### %s%-40s%s: %s\n' \
78 "${BRACKET}" "${GOOD}" "${line%%:*}" "${NORMAL}" "${line#*:}"
82 done < <(echo "${out}")
90 #exec r forall -p -c 'r rb all .' </dev/null
93 branches
=$
(g b |
awk '
95 if ($0 ~ "^[*] *[(]no branch[)]") {
97 } else if ($0 ~ "^[*] *[(]detached from ") {
99 } else if ($1 == "*") {
105 END { print list b }')
106 [[ -z ${branches} ]] && exit 0
108 [[ -z ${GOOD} ]] && eval $
(bash-colors
--env)
109 #echo "${GOOD}### ${PWD}${NORMAL}"
110 # Skip if rebase is in progress.
111 if [[ -e .git
/rebase-merge
/interactive
]] ; then
112 echo -e "# ${_proj}: ${WARN}skipping due to active rebase${NORMAL}"
115 for b
in ${branches} ; do
116 #echo " ${HILITE}### $b${NORMAL}"
118 if ! r rb
-q "$@" ; then
127 cd "${root}" ||
exit 1
129 while read -a line
; do
134 out
=$
(g clean
"$@" 2>&1)
135 if [[ -n ${out} ]] ; then
150 cd "${root}" ||
exit 1
152 if [[ ! -e .repo
/sandbox-url
]] ; then
153 err
"Please configure remote url base in ${root}/.repo/sandbox-url"
155 remote
=$
(<.repo
/sandbox-url
) ||
exit 1
157 echo "pushing projects from ${root}"
159 # ssh servers do not like it when you hammer them :)
160 # Received disconnect from 74.125.248.80: 7: Too many concurrent connections
161 # fatal: The remote end hung up unexpectedly
165 tcnt
=$
(echo "${rlist}" |
wc -l)
170 export GIT_DIR
=${path}/.git
172 printf '### (%*i/%i %3i%%) %s\n' \
173 ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
175 g l
-1 ${src} >& /dev
/null || src
=
176 mj_child g push
--force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev
/null
177 done < <(echo "${rlist}")
183 # For the times when repo is being stupid, push directly to gerrit myself.
184 if ! branch
=$
(g symbolic-ref
-q HEAD
) ; then
185 err
"could not figure out active branch"
187 branch
=${branch#refs/heads/}
188 if ! remote_branch
=$
(g cfg
--get "branch.${branch}.merge") ; then
189 echo "could not figure out remote branch; using ${branch}"
190 remote_branch
=${branch}
192 if ! remote
=$
(g cfg
--get "branch.${branch}.remote") ; then
193 for remote
in cros-internal cros origin
; do
194 g cfg
--get "remote.${remote}.url" >/dev
/null
&& break
197 review
=$
(g cfg
--get "remote.${remote}.review")
198 remote_branch
=${remote_branch#refs/heads/}
202 while [[ $# -gt 0 ]] ; do
208 -n|
--dry-run|
--draft)
212 err
"unknown option: $1"
218 ref_spec
="${branch}:refs/for/${remote_branch}"
219 if [[ -n ${reviewers} ]] ; then
220 reviewers
=( ${reviewers//,/ } )
221 if [[ ${review} != ssh://* ]] ; then
222 gob_args
=$
(printf 'r=%s,' "${reviewers[@]}")
223 ref_spec
+="%${gob_args%,}"
225 git_args
+=( "--receive-pack=git receive-pack ${reviewers[*]/#/--reviewer=}" )
229 vr git push
"${git_args[@]}" ${remote} ${ref_spec} && exit
230 err "could not figure out remote to push to
"
237 while [[ $# -gt 0 ]] ; do
240 if [[ $2 == *"OWNERS
" ]] ; then
241 owners=$(awk -F'@' '{list = list "," $1} END {print substr(list, 2)}' "$2")
242 if [[ -z ${owners} ]] ; then
243 err "cannot
find OWNERS list
"
245 echo "Auto setting reviewers to
: ${owners}"
247 args+=( --re "${owners}" )
259 email=${1:-${USER}@chromium.org}
261 set -- -c "git cfg user.email
${email}"
265 exec repo ${acmd:-${cmd}} "$@
"