]>
Commit | Line | Data |
---|---|---|
3c347239 | 1 | #!/bin/sh |
3c347239 MF |
2 | |
3 | usage() { | |
4 | cat <<-EOF | |
d94e4fb7 | 5 | Usage: repo-cros [options] |
3c347239 | 6 | |
d94e4fb7 | 7 | Options: |
3c347239 MF |
8 | int switch to internal tree |
9 | ext switch to external tree | |
d94e4fb7 MF |
10 | -b <branch> switch branches (use "master" to get to ToT) |
11 | -r <path> patch to reference repo (e.g. ~/chromiumos/) | |
12 | ||
13 | Operates on the repo in ${PWD} | |
3c347239 MF |
14 | EOF |
15 | exit ${1:-1} | |
16 | } | |
3c347239 | 17 | |
a72514e6 | 18 | v() { |
5f57468d | 19 | printf '%s\n%s\n' "${PWD}" "$*" |
a72514e6 | 20 | "$@" |
5f57468d | 21 | } |
3c347239 | 22 | |
d94e4fb7 MF |
23 | email="vapier@chromium.org" |
24 | REF= | |
25 | BRANCH= | |
26 | MANIFEST= | |
27 | REPO_URL= | |
3c347239 MF |
28 | while [[ $# -gt 0 ]] ; do |
29 | case $1 in | |
d94e4fb7 MF |
30 | int) |
31 | MANIFEST='ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal.git' | |
32 | REPO_URL='http://git.chromium.org/external/repo.git' | |
33 | ;; | |
34 | ext) | |
35 | MANIFEST='http://git.chromium.org/chromiumos/manifest.git' | |
36 | REPO_URL='http://git.chromium.org/external/repo.git' | |
37 | ;; | |
38 | -b) | |
39 | BRANCH=$2 | |
40 | shift | |
41 | ;; | |
42 | -r) | |
7dae893b MF |
43 | |
44 | REF=$(realpath "${2:-$(echo ~/chromiumos)}") | |
d94e4fb7 MF |
45 | shift |
46 | ;; | |
5f57468d | 47 | *) |
d94e4fb7 | 48 | usage |
5f57468d | 49 | ;; |
3c347239 | 50 | esac |
5f57468d | 51 | shift |
3c347239 | 52 | done |
d94e4fb7 | 53 | |
a72514e6 MF |
54 | v repo init \ |
55 | ${MANIFEST:+-u "${MANIFEST}"} \ | |
56 | ${REPO_URL:+--repo-url="${REPO_URL}"} \ | |
57 | ${REF:+--reference "${REF}"} \ | |
58 | ${BRANCH:+-b "${BRANCH}"} | |
59 | ||
d94e4fb7 MF |
60 | rdir=$(realpath "`pwd`") |
61 | while [[ ! -d ${rdir}/.repo ]] ; do | |
62 | rdir=${rdir%/*} | |
63 | [[ ${rdir:-/} == "/" ]] && break | |
64 | done | |
65 | rdir+="/.repo" | |
66 | if [[ -d ${rdir} ]] ; then | |
67 | gcfg() { git --git-dir="$1" config user.email "${@:2}" ; } | |
68 | if [[ $(gcfg "${rdir}/manifests.git") != "${email}" ]] ; then | |
69 | echo "${rdir}: setting e-mail to ${email}" | |
70 | find "${rdir}" -type d -name '*.git' | \ | |
71 | while read d ; do | |
72 | gcfg "${d}" ${email} | |
73 | done | |
74 | fi | |
75 | fi | |
76 | ||
a72514e6 | 77 | exit 0 |