+process_reviewers() {
+ local r arr=()
+ for r in ${*//,/ } ; do
+ case ${r} in
+ OWNERS*|*/OWNERS*)
+ local owners=$(
+ awk -F'@' '
+ ($2 == "chromium.org" || $2 == "google.com") {list = list "," $1}
+ END {print substr(list, 2)}
+ ' "${r}"
+ )
+ if [[ -z ${owners} ]] ; then
+ err "cannot find OWNERS list"
+ else
+ echo "Auto setting reviewers to: ${owners}"
+ fi
+ arr+=( ${owners} )
+ ;;
+ *)
+ arr+=( "${r}" )
+ ;;
+ esac
+ done
+ reviewers=$(printf '%s,' "${arr[@]}")
+ reviewers=${reviewers%,}
+}
+
+find_repo() {
+ # Diff projects have diff versions of repo. Find a compatible one.
+ local root=$(repo_root)
+
+ # Use the manifest repo URL.
+ local manifest_dir="${root}/.repo/manifests.git"
+ local d
+
+ # Default to the local repo if it's there.
+ local search=(
+ "${root}/.repo/repo"
+ )
+
+ case $(g --git-dir="${manifest_dir}" config remote.origin.url) in
+ *android*)
+ search+=(
+ /usr/local/src/repo
+ ~/src/repo
+ )
+ ;;
+ *chromium*|*chrome*)
+ search+=(
+ ~/depot_tools
+ ~/chromiumos/depot_tools
+ /usr/local/src/depot_tools
+ ~/src/depot_tools
+ )
+ ;;
+ esac
+ for d in "${search[@]}" ; do
+ if [[ -x ${d}/repo ]] ; then
+ echo "${d}"/repo
+ return
+ fi
+ done
+
+ # Fallback: use $PATH.
+ type -P repo
+}
+