Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: create-chromium-git-src

Issue 2253013004: Remove old unused SVN related scripts from depot_tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome-update-create-task.bat ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env -S bash -e
2 #
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6 #
7 # create-chromium-git-src
8 #
9 # Create and configure a local Chromium git repository.
10 #
11
12 GITSERVER="${GITSERVER:-git.chromium.org}"
13 SVNSERVER="${SVNSERVER:-svn://svn.chromium.org/chrome}"
14 TMP=".create_chromium_git_src.$$"
15
16 function cleanup {
17 rm -rf "${TMP}"
18 }
19
20 trap 'cleanup; echo Failure!; tput bel; exit 1' TERM QUIT HUP INT EXIT
21
22 function get_email {
23 # Get user email address.
24 EMAIL=""
25 while [ "x${EMAIL}" = "x" ]; do
26 echo -n "Email address git should configure in your checkout: "
27 read EMAIL
28 if [ "x${EMAIL}" = "x${EMAIL%@*}" ]; then
29 echo "Invalid email address (must contain @)!"
30 EMAIL=""
31 fi
32 done
33 echo -n "Using ${EMAIL} for email address... "
34 sleep 1
35 echo OK
36 }
37
38 # Verify we can write to particular directories.
39 function check_dirs {
40 if [ -d src ]; then
41 echo "Found a src directory, do you already have a Chromium checkout?"
42 exit 1
43 fi
44 }
45
46 # Test git and git --version.
47 function test_git {
48 echo -n "Trying git... "
49 local GITV="$(git --version)" || {
50 echo "git isn't installed, please install it"
51 exit 1
52 }
53
54 GITV="${GITV##* }" # Only examine last word (i.e. version number)
55 local GITD=( ${GITV//./ } ) # Split version number into decimals
56 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then
57 echo "git version is ${GITV}, please update to a version later than 1.6"
58 exit 1
59 fi
60 echo "found git version ${GITV}"
61 }
62
63 # Test git svn and git svn --version.
64 function test_git_svn {
65 echo -n "Trying git-svn... "
66 rm -rf "${TMP}"
67 git clone git://github.com/git/hello-world.git "${TMP}" &>/dev/null &&
68 local GITV="$(cd "${TMP}" && git svn --version)" || {
69 echo "git-svn isn't installed, please install it"
70 exit 1
71 }
72
73 GITV="${GITV#* version }" # git svn --version has extra output to remove.
74 GITV="${GITV% (svn*}"
75 local GITD=( ${GITV//./ } ) # Split version number into decimals
76 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then
77 echo "git version is ${GITV}, please update to a version later than 1.6"
78 exit 1
79 fi
80 echo "found git-svn version ${GITV}"
81
82 echo "Testing git svn init..."
83 (cd "${TMP}" && git svn init --username="${EMAIL}" --prefix=origin/ \
84 -T trunk/src "${SVNSERVER}") &
85 local pid="$!"
86 { sleep 10 && kill "${pid}"; } &>/dev/null &
87 wait "${pid}" &>/dev/null || {
88 echo "Could not initialize repository, is SVN server ${SVNSERVER} correct?"
89 echo "The supplied username and password may be incorrect."
90 exit 1
91 }
92 }
93
94 # Verify we can reach our main git URL.
95 function test_git_url {
96 echo -n "Testing Chromium git URL... "
97 mkdir -p "${TMP}"
98 (cd "${TMP}" &&
99 rm -rf .git .gitignore &&
100 git init &&
101 git remote add origin git://"${GITSERVER}"/chromium.git &&
102 git remote show origin) &>/dev/null &
103 local pid="$!"
104 { sleep 10 && kill "${pid}"; } &>/dev/null &
105 wait "${pid}" &>/dev/null || {
106 echo "timeout accessing Chromium git URL, is ${GITSERVER} correct?"
107 exit 1
108 }
109 echo OK
110 }
111
112 # Grab a clone of the Chromium git repository.
113 function cr_git_clone {
114 echo "Grabbing Chromium git repository..."
115 git clone git://"${GITSERVER}"/chromium.git src || {
116 echo "git clone exited with error"
117 echo "You should probably remove 'src' before retrying"
118 exit 1
119 }
120 }
121
122 # Configure the git repository to know about the upstream SVN server.
123 function cr_git_svn_init {
124 echo "Configuring upstream SVN..."
125 (cd src && git svn init --username="${EMAIL}" --prefix=origin/ -T trunk/src \
126 "${SVNSERVER}") || {
127 echo "'git svn init' exited with error"
128 exit 1
129 }
130 }
131
132 # Initialize the SVN history in the repository, also sanity checks our upstream
133 # SVN configuration.
134 function cr_git_svn_fetch {
135 echo "Fetching SVN history..."
136 (cd src && git svn fetch && git pull) || {
137 echo "'git svn fetch' exited with error"
138 exit 1
139 }
140 }
141
142 # Remaining configuration of the git repository:
143 # - associate with codereview/rietveld
144 # - set the repository's email address
145 # - disable crlf munging
146 # - grab a stock .gclient file
147 function git_config {
148 echo -n "Associating with Rietveld... "
149 (cd src && git cl config http://src.chromium.org/svn/)
150 echo OK
151
152 echo -n "Configuring email address... "
153 (cd src && git config user.email "${EMAIL}")
154 echo OK
155
156 echo -n "Disabling crlf munging... "
157 (cd src && git config --global core.autocrlf false)
158 echo OK
159
160 echo -n "Creating a .gclient file... "
161 gclient config http://src.chromium.org/svn/trunk/src
162 echo OK
163 }
164
165 get_email
166 check_dirs
167 test_git
168 test_git_svn
169 test_git_url
170 cr_git_clone
171 cr_git_svn_init
172 cr_git_svn_fetch
173 git_config
174
175 echo
176 echo "A Chromium Git repository was created in 'src'."
177 echo
178 echo " To create a CL..."
179 echo " Update: git pull && gclient sync"
180 echo " Create and use a branch mychange: git checkout -q -b mychange origin"
181 echo " Edit files and commit: git commit -a -v"
182 echo " Upload CL: git cl upload"
183 echo " Try a change: git try origin"
184 echo " Commit a CL: git cl dcommit"
185 echo " Switch to the trunk: git checkout trunk"
186 echo " Delete a branch mychange: git branch -d mychange"
187 echo
188 echo " If while on a branch you need to switch back to the trunk..."
189 echo " Switch to the trunk: git checkout trunk"
190 echo " List all branches: git branch"
191 echo " Switch to branch mychange: git checkout mychange"
192 echo
193 echo " Examining files and changes..."
194 echo " Log with patches: git log -p"
195 echo " Changes to DEPS: git log -p DEPS"
196 echo " View latest commit: git cat-file commit HEAD"
197 echo
198 echo "You should run: gclient sync"
199 echo
200 trap cleanup EXIT
OLDNEW
« no previous file with comments | « chrome-update-create-task.bat ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698