OLD | NEW |
---|---|
(Empty) | |
1 #! /bin/bash | |
tfarina
2011/09/06 16:08:52
no spaces between ! and / ?
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
2 # Copyright 2011 the V8 project authors. All rights reserved. | |
3 # Redistribution and use in source and binary forms, with or without | |
4 # modification, are permitted provided that the following conditions are | |
5 # met: | |
6 # | |
7 # * Redistributions of source code must retain the above copyright | |
8 # notice, this list of conditions and the following disclaimer. | |
9 # * Redistributions in binary form must reproduce the above | |
10 # copyright notice, this list of conditions and the following | |
11 # disclaimer in the documentation and/or other materials provided | |
12 # with the distribution. | |
13 # * Neither the name of Google Inc. nor the names of its | |
14 # contributors may be used to endorse or promote products derived | |
15 # from this software without specific prior written permission. | |
16 # | |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | |
29 BRANCHNAME=prepare-push | |
30 TRUNKBRANCH=trunk-push | |
danno
2011/09/06 09:28:55
For safety sake, shouldn't you delete the trunk-pu
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
31 | |
32 # Cancel if this is not a git checkout. | |
33 [[ -d .git ]] || ( | |
34 echo "This is not a git checkout, this script won't work for you. Exiting." | |
35 exit 1 | |
36 ) | |
37 | |
38 # Cancel if EDITOR is unset or not executable. | |
39 [[ -n "$EDITOR" && -x "$EDITOR" ]] || ( | |
40 echo "Please set your EDITOR environment variable, you'll need it. Exiting." | |
41 exit 1 | |
42 ) | |
43 | |
44 echo "Step 1: Fetch unfetched revisions." | |
45 git svn fetch | |
46 | |
47 echo "Step 2: Create a fresh branch." | |
48 if [ -n "$(git branch | grep $BRANCHNAME)" ] ; then | |
mnaganov (inactive)
2011/09/05 21:02:15
Perhaps, you need to check that this isn't the cur
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
49 echo "Branch $BRANCHNAME exists, do you want to delete it? [Y/n]" | |
50 read ANSWER | |
51 if [ -z "$ANSWER" || "$ANSWER" == "Y" || "$ANSWER" == "y" ] ; then | |
52 git branch -D $BRANCHNAME | |
53 echo "Branch $BRANCHNAME deleted, will now re-create it." | |
54 else | |
55 echo "Can't continue. Please delete branch $BRANCHNAME and try again." | |
56 exit 1 | |
57 fi | |
58 fi | |
59 git checkout -b $BRANCHNAME svn/bleeding_edge | |
danno
2011/09/06 09:28:55
You probably want to check that there are no uncom
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
60 | |
61 echo "Step 3: Detect commit ID of last ChangeLog update." | |
62 LASTPUSH=$(git log -1 --format=%H ChangeLog) | |
63 | |
64 echo "Step 4: Prepare raw ChangeLog entry." | |
65 TEMPFILE=$(mktemp) | |
66 # These version numbers are used again later for the trunk commit. | |
67 MAJOR=$(grep "#define MAJOR_VERSION" src/version.cc | awk '{print $NF}') | |
68 MINOR=$(grep "#define MINOR_VERSION" src/version.cc | awk '{print $NF}') | |
69 BUILD=$(grep "#define BUILD_NUMBER" src/version.cc | awk '{print $NF}') | |
70 | |
71 DATE=$(date +%Y-%m-%d) | |
72 echo "$DATE: Version $MAJOR.$MINOR.$BUILD" >> "$TEMPFILE" | |
73 echo "" >> "$TEMPFILE" | |
74 COMMITS=$(git log $LASTPUSH..HEAD --format=%H) | |
75 for commit in $COMMITS ; do | |
76 # Get the commit's title line. | |
77 git log -1 $commit --format="%w(80,8,8)%s" >> "$TEMPFILE" | |
78 # Grep for "BUG=xxxx" lines in the commit message. | |
79 git log -1 $commit --format="%b" | grep BUG= | grep -v "BUG=$" \ | |
80 | sed -e 's/^/ /' >> "$TEMPFILE" | |
81 # Append the commit's author for reference. | |
82 git log -1 $commit --format="%w(80,8,8)(%an)" >> "$TEMPFILE" | |
83 echo "" >> "$TEMPFILE" | |
84 done | |
85 | |
86 echo "Step 5: Edit ChangeLog entry." | |
87 echo "Please press <Return> to have your EDITOR open the ChangeLog entry, \ | |
88 then edit its contents to your liking. When you're done, save the file \ | |
89 and exit your EDITOR." | |
90 read ANSWER | |
91 $EDITOR "$TEMPFILE" | |
92 NEWCHANGELOG=$(mktemp) | |
93 # Eliminate any trailing newlines by going through a shell variable. | |
94 CHANGELOGENTRY=$(cat "$TEMPFILE") | |
95 [[ -n "$CHANGELOGENTRY" ]] && ( | |
96 echo "Empty ChangeLog entry, exiting." | |
97 exit 1 | |
98 ) | |
99 echo "$CHANGELOGENTRY" > "$NEWCHANGELOG" | |
100 echo "" >> "$NEWCHANGELOG" # Explicitly insert two empty lines. | |
101 echo "" >> "$NEWCHANGELOG" | |
102 cat ChangeLog >> "$NEWCHANGELOG" | |
103 mv "$NEWCHANGELOG" ChangeLog | |
104 rm -f "$TEMPFILE" | |
105 | |
106 echo "Step 6: Increment version number." | |
107 echo "Please press <Return> to have your EDITOR open src/version.cc, \ | |
108 then update the version number as appropriate. When you're done, save the \ | |
109 file and exit your EDITOR." | |
110 read ANSWER | |
111 $EDITOR src/version.cc | |
danno
2011/09/06 09:28:55
How about suggesting the next logical version numb
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
112 | |
113 echo "Step 7: Commit to local branch." | |
114 NEWMAJOR=$(grep "#define MAJOR_VERSION" src/version.cc | awk '{print $NF}') | |
115 NEWMINOR=$(grep "#define MINOR_VERSION" src/version.cc | awk '{print $NF}') | |
116 NEWBUILD=$(grep "#define BUILD_NUMBER" src/version.cc | awk '{print $NF}') | |
117 git commit -a -m "Prepare push to trunk. \ | |
118 Now working on version $NEWMAJOR.$NEWMINOR.$NEWBUILD." | |
danno
2011/09/06 09:28:55
Error handling in case something goes wrong?
Jakob Kummerow
2011/09/07 15:46:40
Done. I can't imagine what could go wrong here, th
| |
119 | |
120 echo "Step 8: Upload for code review." | |
121 echo "Please enter the email address of a V8 reviewer for your patch:" | |
122 read REVIEWER | |
123 git cl upload -r $REVIEWER --send-mail | |
danno
2011/09/06 09:28:55
You should probably allow the user to specific --p
Jakob Kummerow
2011/09/07 15:46:40
Done. Each step can be selected as entry point now
| |
124 | |
125 echo "Step 9: Commit to the repository." | |
126 echo "Please wait for an LGTM, then press <Return> to commit your change." | |
127 echo "(If you need to iterate on the patch, do so in another shell.)" | |
128 read ANSWER | |
danno
2011/09/06 09:28:55
If seems a bit fragile, a stray return proceeds wi
Jakob Kummerow
2011/09/07 15:46:40
Done: Error checking added; prevention of stray <R
| |
129 git cl dcommit | |
130 | |
131 echo "Step 10: Fetch fresh commit from the repository." | |
132 git svn rebase # probably not necessary, but who cares... | |
133 | |
danno
2011/09/06 09:28:55
I don't think this does what you want. What it som
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
134 echo "Step 11: Squash commits into one." | |
135 # Instead of relying on "git rebase -i", we'll just create a diff, because | |
136 # that's easier to automate. | |
137 PATCHFILE=$(mktemp) | |
138 git diff svn/trunk > "$PATCHFILE" | |
139 # Convert the ChangeLog entry to commit message format: | |
140 # - remove date | |
141 # - remove indentation | |
142 # - merge paragraphs into single long lines, keeping empty lines between them. | |
143 COMMITMSG=$(mktemp) | |
144 echo "$CHANGELOGENTRY" \ | |
145 | sed -e "s/^$DATE: //" \ | |
146 | sed -e 's/^ *//' \ | |
147 | awk '{ | |
148 if (need_space == 1) { | |
149 printf(" "); | |
150 }; | |
151 printf("%s", $0); | |
152 if ($0 ~ /^$/) { | |
153 printf("\n\n"); | |
154 need_space = 0; | |
155 } else { | |
156 need_space = 1; | |
157 } | |
158 }' > "$COMMITMSG" | |
159 | |
danno
2011/09/06 09:28:55
Might be a good idea to show the resulting commit
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
160 echo "Step 12: Create a new branch from trunk." | |
161 git checkout -b $TRUNKBRANCH svn/trunk | |
mnaganov (inactive)
2011/09/05 21:02:15
Will fail if $TRUNKBRANCH already exists for some
Jakob Kummerow
2011/09/07 15:46:40
Done: $TRUNKBRANCH now gets deleted at the beginni
| |
162 | |
163 echo "Step 13: Apply squashed changes." | |
164 patch -p1 < "$PATCHFILE" | |
danno
2011/09/06 09:28:55
Should probably check for errors applying the patc
Jakob Kummerow
2011/09/07 15:46:40
Done. However, due to the way the patch file is ge
| |
165 rm -f "$PATCHFILE" | |
166 | |
167 echo "Step 14: Set correct version for trunk." | |
168 sed -e "/#define MAJOR_VERSION/s/[0-9]*$/$MAJOR/" \ | |
169 -e "/#define MINOR_VERSION/s/[0-9]*$/$MINOR/" \ | |
170 -e "/#define BUILD_NUMBER/s/[0-9]*$/$BUILD/" \ | |
171 -e "/#define PATCH_LEVEL/s/[0-9]*$/0/" \ | |
172 -e "/#define IS_CANDIDATE_VERSION/s/[0-9]*$/0/" \ | |
173 -i src/version.cc | |
174 | |
175 echo "Step 15: Commit to local trunk branch." | |
176 git add src/version.cc | |
177 git commit -F "$COMMITMSG" | |
danno
2011/09/06 09:28:55
Error handling?
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
178 rm -f "$COMMITMSG" | |
179 | |
180 echo "Step 16: Sanity check." | |
181 echo "Please check if your local checkout is sane: Inspect src/version.cc, \ | |
182 compile, run tests." | |
183 echo "When you're sure you want to commit a new trunk revision to the \ | |
184 repository, press <Return>." | |
185 read ANSWER | |
186 | |
187 echo "Step 17. Commit to SVN." | |
188 git svn dcommit | |
danno
2011/09/06 09:28:55
Error handling, you definitely don't want to make
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
189 | |
190 echo "Step 18: Tag the new revision." | |
191 git svn tag $MAJOR.$MINOR.$BUILD -m "Tagging version $MAJOR.$MINOR.$BUILD" | |
192 | |
193 echo "Step 19: Cleanup." | |
194 git checkout -f master | |
danno
2011/09/06 09:28:55
Not everybody has a master (like me). You probably
Jakob Kummerow
2011/09/07 15:46:40
Done.
| |
195 git branch -D $BRANCHNAME | |
196 git branch -D $TRUNKBRANCH | |
197 | |
198 echo "Step 20: Done!" | |
199 echo "Congratulations, you have successfully created the trunk revision \ | |
200 $MAJOR.$MINOR.$BUILD." | |
201 echo "Please don't forget to update the v8rel spreadsheet, and \ | |
danno
2011/09/06 09:28:55
For extra points and the respect of the entire tea
Jakob Kummerow
2011/09/07 15:46:40
Advanced feature -> post-V1 ;-)
| |
202 to roll this new version into Chromium." | |
OLD | NEW |