#!/bin/sh usage() { cat <<-EOF Usage: repo-cros [options] Options: int switch to internal tree ext switch to external tree -b switch branches (use "master" to get to ToT) -r patch to reference repo (e.g. ~/chromiumos/) Operates on the repo in ${PWD} EOF exit ${1:-1} } vexec() { printf '%s\n%s\n' "${PWD}" "$*" exec "$@" } email="vapier@chromium.org" REF= BRANCH= MANIFEST= REPO_URL= while [[ $# -gt 0 ]] ; do case $1 in int) MANIFEST='ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal.git' REPO_URL='http://git.chromium.org/external/repo.git' ;; ext) MANIFEST='http://git.chromium.org/chromiumos/manifest.git' REPO_URL='http://git.chromium.org/external/repo.git' ;; -b) BRANCH=$2 shift ;; -r) REF=$(realpath "$2") shift ;; *) usage ;; esac shift done rdir=$(realpath "`pwd`") while [[ ! -d ${rdir}/.repo ]] ; do rdir=${rdir%/*} [[ ${rdir:-/} == "/" ]] && break done rdir+="/.repo" if [[ -d ${rdir} ]] ; then gcfg() { git --git-dir="$1" config user.email "${@:2}" ; } if [[ $(gcfg "${rdir}/manifests.git") != "${email}" ]] ; then echo "${rdir}: setting e-mail to ${email}" find "${rdir}" -type d -name '*.git' | \ while read d ; do gcfg "${d}" ${email} done fi fi vexec \ repo init \ ${MANIFEST:+-u "${MANIFEST}"} \ ${REPO_URL:+--repo-url="${REPO_URL}"} \ ${REF:+--reference "${REF}"} \ ${BRANCH:+-b "${BRANCH}"}