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

Side by Side Diff: crup-runner.sh

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: address comments 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 | « no previous file | git-crsync » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
3 update_toplevel () {
4 # Don't "pull" if checkout is not on a named branch
5 if test "$2" = "pull" && ( ! git symbolic-ref HEAD >/dev/null 2>/dev/null ); t hen
6 first_args="$1 fetch"
7 else
8 first_args="$1 $2"
9 fi
10 shift 2
11 echo "[$solution] $first_args $@" 1>&2
12 $first_args $@ | sed "s/^/[$solution] /g" 1>&2
13 status=$?
14 if [ "$status" -ne 0 ]; then
15 exit $status
16 fi
17 }
18
19 set_target_os () {
20 # Get the os we're building for. On first run, this will be unset.
21 target_os=$(git config --get-all target.os 2>/dev/null)
22 if [ -z "$target_os" ]; then
23 case $(uname -s) in
24 Linux) target_os=unix ;;
25 Darwin) target_os=mac ;;
26 CYGWIN*|MINGW*) target_os=win ;;
27 *)
28 echo "[$solution] *** No target.os set in .git/config, and I can't" 1>&2
29 echo "[$solution] *** figure it out from 'uname -s'" 1>&2
30 exit 1
31 ;;
32 esac
33 git config target.os "$target_os"
34 fi
35 }
36
37 update_submodule_url () {
38 # If the submodule's URL in .gitmodules has changed, propagate the new
39 # new URL down. This is the same as `git submodule sync`, but we do it
40 # this way because `git submodule sync` is absurdly slow.
41 new_url=$(git config -f .gitmodules "submodule.$1.url" 2>/dev/null)
42 old_url=$(git config "submodule.$1.url" 2>/dev/null)
43 if [ "$new_url" != "$old_url" ]; then
44 git config "submodule.$1.url" "$new_url"
45 if [ -e "$1"/.git ]; then
46 ( cd $submod && git config remote.origin.url "$new_url" )
47 fi
48 fi
49 }
50
51 process_submodule () {
52 # Check whether this submodule should be ignored or updated.
53 # If it's a new submodule, match the os specified in .gitmodules against
54 # the os specified in .git/config.
55 update_policy=$(git config --get "submodule.$1.update")
56 if [ -z "$update_policy" ]; then
57 submod_os=$(git config -f .gitmodules --get "submodule.$1.os")
58 if [ -n "$submod_os" -a "$submod_os" != "all" ]; then
59 update_policy=none
60 for os in $target_os; do
61 if [ "${submod_os/${os}/}" != "${submod_os}" ]; then
62 update_policy=checkout
63 fi
64 done
65 else
66 update_policy=checkout
67 fi
68 if [ "$update_policy" != "none" ]; then
69 git submodule --quiet init "$1"
70 fi
71 git config "submodule.$1.update" $update_policy
72 fi
73 ignore_policy=$(git config --get "submodule.$1.ignore")
74 if [ -z "$ignore_policy" ]; then
75 git config "submodule.$1.ignore" all
76 fi
77 if [ "$update_policy" != "none" ]; then
78 update_submodule_url "$1"
79 echo "$solution/$1"
80 fi
81 }
82
83 if [ -z "$*" ]; then
84 exit 0
85 fi
86 set -o pipefail
87 dir="$1"
88 solution="${1%%/*}"
89 cd "$solution" 1>/dev/null
90
91 if [ "$solution" = "$1" ]; then
92 # Skip git checkouts not managed by crup.
93 gitdir="$(git rev-parse --git-dir)"
94 if ! grep -q -s "The Chromium Authors" "$gitdir/description"; then
95 echo "Skipping unmanaged git directory $1" 1>&2
96 exit 0
97 fi
98
99 # Set default behavior to ignore diffs in submodule checkouts
100 diff_policy=$(git config --get "diff.ignoreSubmodules")
101 if [ -z "$diff_policy" ]; then
102 git config diff.ignoreSubmodules all
103 fi
104
105 # Don't "pull" if checkout is not on a named branch
106 shift
107 if test $# -ne 0; then
108 update_toplevel "$@"
109 fi
110
111 set_target_os
112
113 git ls-files -s | grep ^160000 | awk '{print $4}' |
114 while read submod; do
115 process_submodule "$submod"
116 done
117 status=$?
118 else
119 submodule="${1#*/}"
120 echo "[$solution] updating $submodule"
121 git submodule update --recursive --quiet "$submodule" |
122 ( grep -v '^Skipping submodule' || true ) | sed "s|^|[$1] |g" 2>/dev/null
123 status=$?
124 if [ "$status" -ne "0" ]; then
125 echo "[$solution] FAILED to update $submodule"
126 fi
127 fi
128 exit $status
OLDNEW
« no previous file with comments | « no previous file | git-crsync » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698