usage() {
cat <<-EOF
- Usage: repo-cros [dir] <command> [command opts]
+ Usage: repo-cros [options]
- Commands:
+ Options:
int switch to internal tree
ext switch to external tree
- -b <branch> switch branches
+ -b <branch> switch branches (use "master" to get to ToT)
+ -r <path> 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}"}