3 err() { printf '%b\n' "$*" 1>&2; exit 1; }
4 vr() { echo "$@"; "$@"; }
22 exec {ctlfd}<>"${pipe}"
25 jobs_max=${1:-$(getconf _NPROCESSORS_ONLN)}
27 _mj_child() { echo ${BASHPID} $? >&${ctlfd} ; }
37 if [[ ${jobs} -eq ${jobs_max} ]] ; then
38 read -r -u ${ctlfd} pid ret
48 while [[ ! -d ${root}/.repo && ${root:-/} != "/" ]] ; do
56 for r in ${*//,/ } ; do
61 ($2 == "chromium.org" || $2 == "google.com") {list = list "," $1}
62 END {print substr(list, 2)}
65 if [[ -z ${owners} ]] ; then
66 err "cannot find OWNERS list"
68 echo "Auto setting reviewers to: ${owners}"
77 reviewers=$(printf '%s,' "${arr[@]}")
78 reviewers=${reviewers%,}
82 # Diff projects have diff versions of repo. Find a compatible one.
83 local root=$(repo_root)
85 # Use the manifest repo URL.
86 local manifest_dir="${root}/.repo/manifests.git"
89 # Default to the local repo if it's there.
94 case $(g --git-dir="${manifest_dir}" config remote.origin.url) in
104 ~/chromiumos/depot_tools
105 /usr/local/src/depot_tools
110 for d in "${search[@]}" ; do
111 if [[ -x ${d}/repo ]] ; then
117 # Fallback: use $PATH.
121 case ${acmd:-${cmd}} in
123 if [[ $1 == "all" ]] ; then
125 if [[ $# -eq 0 ]] ; then
126 # This bash version is still slightly faster than repo!
127 #exec r forall -j$(getconf _NPROCESSORS_ONLN) -p -c git rb-all
129 eval "$(bash-colors --env | sed 's:^:export :')"
132 while read -a line ; do
135 if ! cd "${root}/${dir}" ; then
140 out=$(r rb-all . 2>&1)
141 if [[ -n ${out} ]] ; then
142 head=$(printf "%-40s" "${proj}")
143 echo "${out}" | sed "s:^:${head} :"
158 cd "${root}" || exit 1
160 while read -a line ; do
165 out=$(g clean "$@" 2>&1)
166 if [[ -n ${out} ]] ; then
182 f|fetch) sb_cmd="fetch" ;;
183 *) err "unknown sandbox command: $1"
189 cd "${root}" || exit 1
191 if [[ ! -e .repo/sandbox-url ]] ; then
192 err "Please configure remote url base in ${root}/.repo/sandbox-url"
194 remote=$(<.repo/sandbox-url) || exit 1
196 echo "pushing projects from ${root}"
198 # ssh servers do not like it when you hammer them :)
199 # Received disconnect from 74.125.248.80: 7: Too many concurrent connections
200 # fatal: The remote end hung up unexpectedly
204 tcnt=$(echo "${rlist}" | wc -l)
209 export GIT_DIR=${path}/.git
211 printf '### (%*i/%i %3i%%) %s\n' \
212 ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
216 g l -1 ${src} >& /dev/null || src=
217 mj_child g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null
222 mj_child g fetch ${remote}/${proj} refs/sandbox/${USER}/${sync_branch}:refs/remotes/sb/${sync_branch} >/dev/null
225 done < <(echo "${rlist}")
232 while [[ $# -gt 0 ]] ; do
235 process_reviewers "$2"
236 args+=( --re "${reviewers}" )
247 email=${1:-${USER}@chromium.org}
250 git --git-dir="${root}/.repo/manifests.git" cfg user.email "${email}"
251 git --git-dir="${root}/.repo/repo/.git" cfg user.email "${email}"
254 set -- -c "git cfg user.email '${email}'"
258 exec $(find_repo) ${acmd:-${cmd}} "$@"