OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 force_branch=no | 7 branch_name="" |
8 checkout_branch=no | |
9 create_branch=no | |
8 quiet=no | 10 quiet=no |
9 | 11 |
10 while [ $# -gt 0 ]; do | 12 while [ $# -gt 0 ]; do |
11 case "$1" in | 13 case "$1" in |
12 --force-branch) | 14 --checkout|--force-branch) |
13 force_branch=yes | 15 checkout_branch=yes |
16 ;; | |
17 --create) | |
18 create_branch=yes | |
19 ;; | |
20 -n|--name) | |
21 branch_name=$2 | |
22 create_branch=yes | |
23 shift | |
14 ;; | 24 ;; |
15 -q|--quiet) | 25 -q|--quiet) |
16 quiet=yes | 26 quiet=yes |
17 ;; | 27 ;; |
18 *) | 28 *) |
19 echo "Unknown option: $1" | 29 echo "Unknown option: $1" |
30 echo "Usage:" | |
31 echo " --checkout Create a branch and check it out." | |
32 echo " --create Create a branch." | |
33 echo " -n, --name <name> Specify the name of branch to create or reset." | |
34 echo " This will force the branch using 'git branch -f '." | |
35 echo " -q, --quiet Quiet." | |
36 exit 1 | |
20 ;; | 37 ;; |
21 esac | 38 esac |
22 shift | 39 shift |
23 done | 40 done |
24 | 41 |
25 svn_lkgr=`curl -s http://chromium-status.appspot.com/lkgr` | 42 svn_lkgr=`curl -s http://chromium-status.appspot.com/lkgr` |
26 if [ $? != 0 -o -z "$svn_lkgr" ]; then | 43 if [ $? != 0 -o -z "$svn_lkgr" ]; then |
27 echo 'Could not get svn lkgr from chromium-status.appspot.com/lkgr' | 44 echo 'Could not get svn lkgr from chromium-status.appspot.com/lkgr' |
28 exit 1 | 45 exit 1 |
29 fi | 46 fi |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 fi | 80 fi |
64 | 81 |
65 closest_svn_commit=`git rev-list -n 1 ${closest_commit}^1` | 82 closest_svn_commit=`git rev-list -n 1 ${closest_commit}^1` |
66 if [ $? != 0 -o -z "$closest_svn_commit" ]; then | 83 if [ $? != 0 -o -z "$closest_svn_commit" ]; then |
67 cat <<EOF 1>&2 | 84 cat <<EOF 1>&2 |
68 I am thoroughly confused. Please file a bug report at http://new.crbug.com. | 85 I am thoroughly confused. Please file a bug report at http://new.crbug.com. |
69 EOF | 86 EOF |
70 exit 1 | 87 exit 1 |
71 fi | 88 fi |
72 | 89 |
73 # Pick a name for the new branch. Use `git rev-parse` to make sure the branch | 90 if [ "${branch_name}" != "" ]; then |
74 # doesn't already exist; if it does, iterate an integer suffix to uniquify it. | 91 lkgr_branch="${branch_name}" |
75 lkgr_branch="git_lkgr_r${svn_lkgr}" | 92 else |
76 digit=1 | 93 # Pick a name for the new branch. Use `git rev-parse` to make sure the branch |
77 git rev-parse --verify -q "${lkgr_branch}" >/dev/null | 94 # doesn't already exist; if it does, iterate an integer suffix to uniquify it. |
78 while [ $? -eq 0 ]; do | 95 lkgr_branch="lkgr_r${svn_lkgr}" |
79 lkgr_branch="git_lkgr_r${svn_lkgr}_${digit}" | 96 digit=1 |
80 digit=`expr $digit + 1` | |
81 git rev-parse --verify -q "${lkgr_branch}" >/dev/null | 97 git rev-parse --verify -q "${lkgr_branch}" >/dev/null |
82 done | 98 while [ $? -eq 0 ]; do |
99 lkgr_branch="lkgr_r${svn_lkgr}_${digit}" | |
100 digit=`expr $digit + 1` | |
101 git rev-parse --verify -q "${lkgr_branch}" >/dev/null | |
102 done | |
103 fi | |
83 | 104 |
84 if [ "${closest_svn_commit}" = "${git_lkgr}" ]; then | 105 if [ "${closest_svn_commit}" = "${git_lkgr}" ]; then |
85 echo "${closest_commit}" | 106 echo "${closest_commit}" |
86 if [ "$force_branch" = "yes" ]; then | 107 if [ "$create_branch" = "yes" ] || [ "$checkout_branch" = "yes" ]; then |
87 git checkout -b "${lkgr_branch}" "${closest_commit}" | 108 # If the branch exists, update it, else create it |
109 git rev-parse --verify -q "${lkgr_branch}" >/dev/null | |
110 if [ $? -eq 0 ]; then | |
111 git branch -f "${lkgr_branch}" "${closest_commit}" | |
112 echo "Updated branch ${lkgr_branch}" | |
113 else | |
114 git branch "${lkgr_branch}" "${closest_commit}" | |
115 echo "Created branch ${lkgr_branch}" | |
116 fi | |
117 fi | |
118 if [ "$checkout_branch" = "yes" ]; then | |
119 git checkout "${lkgr_branch}" | |
88 fi | 120 fi |
89 exit 0 | 121 exit 0 |
90 elif [ "${quiet}" = "yes" ]; then | 122 elif [ "${quiet}" = "yes" ]; then |
91 exit 1 | 123 exit 1 |
92 elif [ "${force_branch}" = "no" ]; then | 124 elif [ "${checkout_branch}" = "no" ]; then |
szager1
2013/01/16 00:46:05
elif [ "${checkout_branch}" = "no" -a "${create_br
scheib
2013/01/16 21:26:56
Done by asking the user to use --checkout if they
| |
93 cat <<EOF | 125 cat <<EOF |
94 There is no master commit which corresponds exactly to lkgr. | 126 There is no master commit which corresponds exactly to lkgr. |
95 The closest commit is ${closest_commit}. | 127 The closest commit is ${closest_commit}. |
96 EOF | 128 EOF |
97 read -n 1 -p 'Would you like to create a new branch based on lkgr? (y/N) ' | 129 read -n 1 -p 'Would you like to create a new branch based on lkgr? (y/N) ' |
98 echo | 130 echo |
99 if [ "x$REPLY" != "xy" -a "x$REPLY" != "xY" ]; then | 131 if [ "x$REPLY" != "xy" -a "x$REPLY" != "xY" ]; then |
100 exit 0 | 132 exit 0 |
101 fi | 133 fi |
102 fi | 134 fi |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 To create a working branch, do this: | 174 To create a working branch, do this: |
143 | 175 |
144 \$ git branch --track my_new_branch $lkgr_branch | 176 \$ git branch --track my_new_branch $lkgr_branch |
145 | 177 |
146 'git-cl upload' will do the right thing, i.e., it will cherry-pick all | 178 'git-cl upload' will do the right thing, i.e., it will cherry-pick all |
147 your changes from my_new_branch, but *not* the .DEPS.git+.gitmodules+submodules | 179 your changes from my_new_branch, but *not* the .DEPS.git+.gitmodules+submodules |
148 commit on $lkgr_branch. | 180 commit on $lkgr_branch. |
149 -------------------------------------------------------------------------------- | 181 -------------------------------------------------------------------------------- |
150 | 182 |
151 EOF | 183 EOF |
OLD | NEW |