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

Side by Side Diff: git-crup

Issue 271983002: Remove git-cr{up,sync} and replace with informative shell script. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: quotes Created 6 years, 7 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 | « git-crsync ('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
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # A convenience script to largely replicate the behavior of `gclient sync` in a 6 TOPLEVEL=$(git rev-parse --show-toplevel)
7 # submodule-based checkout. Fetches latest commits for top-level solutions; 7 TOPPERLEVEL=$(dirname $TOPLEVEL)
8 # updates submodules; and runs post-sync hooks.
9 8
10 orig_args="$@" 9 echo Sorry `whoami`, but the git-submodule flow has been deprecated
11 ECHO= 10 echo in order to simplify the plethora of SCM choices, and to pave the way
12 pull=pull 11 echo towards a git-only chromium development flow.
13 pull_args= 12 echo
14 hooks=yes 13 echo Please consult https://code.google.com/p/chromium/wiki/UsingGitSubmodules
iannucci 2014/05/08 21:52:30 Link is up here. Updated with anchor in new Patchs
15 j=10 14 echo for instructions on how to convert your submodule checkout to gclient.
16 crup_runner="crup-runner.sh" 15 echo
16 echo The simplest chromium and/or blink instructions follow for convenience.
17 echo
18 echo 1. Make sure the parent directory of this checkout is empty, besides this r epo:
19 echo $ ls $TOPPERLEVEL
20 ls "$TOPPERLEVEL"
21 contents=$(ls "$TOPPERLEVEL")
22 if [[ "$contents" != 'src' ]]
23 then
24 echo Please move this repo to its own directory before continuing!!!
25 fi
26 echo
27 echo 2. Please add a .gclient file to $TOPPERLEVEL/.gclient of the form:
28 cat <<EOF
szager1 2014/05/08 21:46:39 This would read better if you here-filed the whole
iannucci 2014/05/08 21:52:30 Done. (see above)
29 # ======== .gclient begins =========
30 solutions = [{
31 'name': '$(basename "$TOPLEVEL")',
32 'url': 'https://chromium.googlesource.com/chromium/src.git',
33 'managed': False,
34 'deps_file': '.DEPS.git',
35 # Uncomment the following if you're doing blink development
36 # 'custom_vars': {'webkit_rev': ''},
37 }]
38 # ======== .gclient ends =========
39 EOF
40 echo
41 echo 3. Run \`gclient sync\` to synchronize dependencies in your checkout instea d of $(basename "$0")!
17 42
18 usage() { 43 exit 1
19 cat <<EOF
20 Usage: git-crup [-n|--dry-run] [--fetch|--sync] [-j|--jobs [jobs]]
21 [--no-hooks] [<args to git-pull or git-fetch>]
22
23 -n, --dry-run Don't do anything; just show what would have been done.
24 --fetch Run 'git fetch' on top-level sources, but don't merge.
25 --sync Don't do anything at all to the top-level sources.
26 -j, --jobs Run this many jobs in parallel.
27 --no-hooks Don't run hooks (e.g., to generate build files) after
28 updating.
29 EOF
30 }
31
32 serial_update() {
33 ( cd "$1"
34 if test -n "$toplevel_cmd"; then
35 $ECHO $toplevel_cmd | sed "s/^/[$1] /g"
36 if [ $? -ne 0 ]; then
37 return $?
38 fi
39 fi
40 $ECHO git submodule --quiet sync
41 $ECHO git ls-files -s | grep ^160000 | awk '{print $4}' |
42 while read submod; do
43 $ECHO "$crup_runner" "$1/$submod"
44 done
45 )
46 }
47
48 while test $# -ne 0; do
49 case "$1" in
50 -j[0-9]*)
51 j=$(echo "$1" | cut -c3-)
52 ;;
53 --jobs=[0-9]*)
54 j=$(echo "$1" | cut -c8-)
55 ;;
56 -j|--jobs)
57 case "$2" in
58 ''|-*)
59 j=0
60 ;;
61 *)
62 j="$2"
63 shift
64 ;;
65 esac
66 ;;
67 -n|--dry-run)
68 ECHO=echo
69 ;;
70 -h|--help)
71 usage
72 exit 0
73 ;;
74 --fetch)
75 pull=fetch
76 ;;
77 --sync)
78 pull=
79 ;;
80 --no-hooks|--nohooks)
81 hooks=no
82 ;;
83 *)
84 pull_args="$pull_args $1"
85 break
86 ;;
87 esac
88 shift
89 done
90
91 # Auto-update depot_tools.
92 if [ -z "$GIT_CRUP_REINVOKE" ]; then
93 kernel_name="\$(uname -s)"
94 if [ "\${kernel_name:0:5}" = "MINGW" ]; then
95 cmd '/C update_depot_tools.bat'
96 else
97 update_depot_tools
98 fi
99 GIT_CRUP_REINVOKE=1 exec bash "$0" $orig_args
100 fi
101
102 while test "$PWD" != "/"; do
103 if test -f "$PWD/src/.gitmodules"; then
104 break
105 fi
106 cd ..
107 done
108 if test "$PWD" = "/"; then
109 echo "Could not find the root of your checkout; aborting." 1>&2
110 exit 1
111 fi
112
113 export GIT_MERGE_AUTOEDIT=no
114
115 if ( echo test | xargs --max-lines=1 true 2>/dev/null ); then
116 max_lines="--max-lines=1"
117 else
118 max_lines="-L 1"
119 fi
120
121 if ( echo test | xargs -I bar true 2>/dev/null ); then
122 replace_arg="-I replace_arg"
123 else
124 replace_arg="-ireplace_arg"
125 fi
126
127 if ( echo test test | xargs -P 2 true 2>/dev/null ); then
128 xargs_parallel=yes
129 else
130 if test "$j" != "1"; then
131 echo "Warning: parallel execution is not supported on this platform." 1>&2
132 fi
133 xargs_parallel=no
134 fi
135
136 if test -n "$pull"; then
137 toplevel_cmd="git $pull $pull_args -q origin"
138 else
139 toplevel_cmd=
140 fi
141
142 set -o pipefail
143 if test "$xargs_parallel" = "yes"; then
144 ( ls -d */.git | sed 's/\/\.git$//' |
145 xargs $max_lines $replace_arg -P "$j" \
146 "$crup_runner" replace_arg $ECHO $toplevel_cmd |
147 xargs $max_lines -P "$j" $ECHO "$crup_runner" )
148 else
149 ls -d */.git |
150 while read gitdir; do
151 serial_update "${gitdir%%/.git}"
152 done
153 fi
154
155 status=$?
156
157 if [ "$status" -ne 0 ]; then
158 cat 1>&2 <<EOF
159 Please check the preceding terminal output for error messages.
160 Run 'git submodule status' to see the current state of submodule checkouts.
161 EOF
162 exit $status
163 fi
164
165 if [ "$hooks" = "yes" ]; then
166 $ECHO git runhooks
167 status=$?
168 fi
169
170 echo
171 exit $status
OLDNEW
« no previous file with comments | « git-crsync ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698