From d94e4fb7abee235675bb1cb6a8808007e7919e48 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 8 Jun 2012 22:54:36 -0400 Subject: [PATCH] add reference support, and initialize e-mail --- .bin/cros-repo | 67 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/.bin/cros-repo b/.bin/cros-repo index 6f51357..3da6b5c 100755 --- a/.bin/cros-repo +++ b/.bin/cros-repo @@ -2,37 +2,74 @@ usage() { cat <<-EOF - Usage: repo-cros [dir] [command opts] + Usage: repo-cros [options] - Commands: + Options: int switch to internal tree ext switch to external tree - -b switch branches + -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} } -[[ $# -eq 0 ]] && usage vexec() { - cd ${DIR:-~/chromiumos} printf '%s\n%s\n' "${PWD}" "$*" exec "$@" } -DIR= +email="vapier@chromium.org" +REF= +BRANCH= +MANIFEST= +REPO_URL= while [[ $# -gt 0 ]] ; do case $1 in - int) vexec repo init -u ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal.git --repo-url='http://git.chromium.org/external/repo.git' ;; - ext) vexec repo init -u http://git.chromium.org/chromiumos/manifest.git --repo-url http://git.chromium.org/external/repo.git ;; - -b) vexec repo init -b $2 ;; + 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 + ;; *) - if [[ -z ${DIR} ]] ; then - DIR=$1 - else - usage - fi + usage ;; esac shift done -exit 0 + +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}"} -- 2.39.5