Index: push-to-trunk.sh |
diff --git a/push-to-trunk.sh b/push-to-trunk.sh |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0c4ba63da7c447641c4ef99002d573d5ca0aa6b2 |
--- /dev/null |
+++ b/push-to-trunk.sh |
@@ -0,0 +1,202 @@ |
+#! /bin/bash |
tfarina
2011/09/06 16:08:52
no spaces between ! and / ?
Jakob Kummerow
2011/09/07 15:46:40
Done.
|
+# Copyright 2011 the V8 project authors. All rights reserved. |
+# Redistribution and use in source and binary forms, with or without |
+# modification, are permitted provided that the following conditions are |
+# met: |
+# |
+# * Redistributions of source code must retain the above copyright |
+# notice, this list of conditions and the following disclaimer. |
+# * Redistributions in binary form must reproduce the above |
+# copyright notice, this list of conditions and the following |
+# disclaimer in the documentation and/or other materials provided |
+# with the distribution. |
+# * Neither the name of Google Inc. nor the names of its |
+# contributors may be used to endorse or promote products derived |
+# from this software without specific prior written permission. |
+# |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ |
+BRANCHNAME=prepare-push |
+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.
|
+ |
+# Cancel if this is not a git checkout. |
+[[ -d .git ]] || ( |
+ echo "This is not a git checkout, this script won't work for you. Exiting." |
+ exit 1 |
+) |
+ |
+# Cancel if EDITOR is unset or not executable. |
+[[ -n "$EDITOR" && -x "$EDITOR" ]] || ( |
+ echo "Please set your EDITOR environment variable, you'll need it. Exiting." |
+ exit 1 |
+) |
+ |
+echo "Step 1: Fetch unfetched revisions." |
+git svn fetch |
+ |
+echo "Step 2: Create a fresh branch." |
+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.
|
+ echo "Branch $BRANCHNAME exists, do you want to delete it? [Y/n]" |
+ read ANSWER |
+ if [ -z "$ANSWER" || "$ANSWER" == "Y" || "$ANSWER" == "y" ] ; then |
+ git branch -D $BRANCHNAME |
+ echo "Branch $BRANCHNAME deleted, will now re-create it." |
+ else |
+ echo "Can't continue. Please delete branch $BRANCHNAME and try again." |
+ exit 1 |
+ fi |
+fi |
+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.
|
+ |
+echo "Step 3: Detect commit ID of last ChangeLog update." |
+LASTPUSH=$(git log -1 --format=%H ChangeLog) |
+ |
+echo "Step 4: Prepare raw ChangeLog entry." |
+TEMPFILE=$(mktemp) |
+# These version numbers are used again later for the trunk commit. |
+MAJOR=$(grep "#define MAJOR_VERSION" src/version.cc | awk '{print $NF}') |
+MINOR=$(grep "#define MINOR_VERSION" src/version.cc | awk '{print $NF}') |
+BUILD=$(grep "#define BUILD_NUMBER" src/version.cc | awk '{print $NF}') |
+ |
+DATE=$(date +%Y-%m-%d) |
+echo "$DATE: Version $MAJOR.$MINOR.$BUILD" >> "$TEMPFILE" |
+echo "" >> "$TEMPFILE" |
+COMMITS=$(git log $LASTPUSH..HEAD --format=%H) |
+for commit in $COMMITS ; do |
+ # Get the commit's title line. |
+ git log -1 $commit --format="%w(80,8,8)%s" >> "$TEMPFILE" |
+ # Grep for "BUG=xxxx" lines in the commit message. |
+ git log -1 $commit --format="%b" | grep BUG= | grep -v "BUG=$" \ |
+ | sed -e 's/^/ /' >> "$TEMPFILE" |
+ # Append the commit's author for reference. |
+ git log -1 $commit --format="%w(80,8,8)(%an)" >> "$TEMPFILE" |
+ echo "" >> "$TEMPFILE" |
+done |
+ |
+echo "Step 5: Edit ChangeLog entry." |
+echo "Please press <Return> to have your EDITOR open the ChangeLog entry, \ |
+then edit its contents to your liking. When you're done, save the file \ |
+and exit your EDITOR." |
+read ANSWER |
+$EDITOR "$TEMPFILE" |
+NEWCHANGELOG=$(mktemp) |
+# Eliminate any trailing newlines by going through a shell variable. |
+CHANGELOGENTRY=$(cat "$TEMPFILE") |
+[[ -n "$CHANGELOGENTRY" ]] && ( |
+ echo "Empty ChangeLog entry, exiting." |
+ exit 1 |
+) |
+echo "$CHANGELOGENTRY" > "$NEWCHANGELOG" |
+echo "" >> "$NEWCHANGELOG" # Explicitly insert two empty lines. |
+echo "" >> "$NEWCHANGELOG" |
+cat ChangeLog >> "$NEWCHANGELOG" |
+mv "$NEWCHANGELOG" ChangeLog |
+rm -f "$TEMPFILE" |
+ |
+echo "Step 6: Increment version number." |
+echo "Please press <Return> to have your EDITOR open src/version.cc, \ |
+then update the version number as appropriate. When you're done, save the \ |
+file and exit your EDITOR." |
+read ANSWER |
+$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.
|
+ |
+echo "Step 7: Commit to local branch." |
+NEWMAJOR=$(grep "#define MAJOR_VERSION" src/version.cc | awk '{print $NF}') |
+NEWMINOR=$(grep "#define MINOR_VERSION" src/version.cc | awk '{print $NF}') |
+NEWBUILD=$(grep "#define BUILD_NUMBER" src/version.cc | awk '{print $NF}') |
+git commit -a -m "Prepare push to trunk. \ |
+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
|
+ |
+echo "Step 8: Upload for code review." |
+echo "Please enter the email address of a V8 reviewer for your patch:" |
+read REVIEWER |
+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
|
+ |
+echo "Step 9: Commit to the repository." |
+echo "Please wait for an LGTM, then press <Return> to commit your change." |
+echo "(If you need to iterate on the patch, do so in another shell.)" |
+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
|
+git cl dcommit |
+ |
+echo "Step 10: Fetch fresh commit from the repository." |
+git svn rebase # probably not necessary, but who cares... |
+ |
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.
|
+echo "Step 11: Squash commits into one." |
+# Instead of relying on "git rebase -i", we'll just create a diff, because |
+# that's easier to automate. |
+PATCHFILE=$(mktemp) |
+git diff svn/trunk > "$PATCHFILE" |
+# Convert the ChangeLog entry to commit message format: |
+# - remove date |
+# - remove indentation |
+# - merge paragraphs into single long lines, keeping empty lines between them. |
+COMMITMSG=$(mktemp) |
+echo "$CHANGELOGENTRY" \ |
+ | sed -e "s/^$DATE: //" \ |
+ | sed -e 's/^ *//' \ |
+ | awk '{ |
+ if (need_space == 1) { |
+ printf(" "); |
+ }; |
+ printf("%s", $0); |
+ if ($0 ~ /^$/) { |
+ printf("\n\n"); |
+ need_space = 0; |
+ } else { |
+ need_space = 1; |
+ } |
+ }' > "$COMMITMSG" |
+ |
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.
|
+echo "Step 12: Create a new branch from trunk." |
+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
|
+ |
+echo "Step 13: Apply squashed changes." |
+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
|
+rm -f "$PATCHFILE" |
+ |
+echo "Step 14: Set correct version for trunk." |
+sed -e "/#define MAJOR_VERSION/s/[0-9]*$/$MAJOR/" \ |
+ -e "/#define MINOR_VERSION/s/[0-9]*$/$MINOR/" \ |
+ -e "/#define BUILD_NUMBER/s/[0-9]*$/$BUILD/" \ |
+ -e "/#define PATCH_LEVEL/s/[0-9]*$/0/" \ |
+ -e "/#define IS_CANDIDATE_VERSION/s/[0-9]*$/0/" \ |
+ -i src/version.cc |
+ |
+echo "Step 15: Commit to local trunk branch." |
+git add src/version.cc |
+git commit -F "$COMMITMSG" |
danno
2011/09/06 09:28:55
Error handling?
Jakob Kummerow
2011/09/07 15:46:40
Done.
|
+rm -f "$COMMITMSG" |
+ |
+echo "Step 16: Sanity check." |
+echo "Please check if your local checkout is sane: Inspect src/version.cc, \ |
+compile, run tests." |
+echo "When you're sure you want to commit a new trunk revision to the \ |
+repository, press <Return>." |
+read ANSWER |
+ |
+echo "Step 17. Commit to SVN." |
+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.
|
+ |
+echo "Step 18: Tag the new revision." |
+git svn tag $MAJOR.$MINOR.$BUILD -m "Tagging version $MAJOR.$MINOR.$BUILD" |
+ |
+echo "Step 19: Cleanup." |
+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.
|
+git branch -D $BRANCHNAME |
+git branch -D $TRUNKBRANCH |
+ |
+echo "Step 20: Done!" |
+echo "Congratulations, you have successfully created the trunk revision \ |
+$MAJOR.$MINOR.$BUILD." |
+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 ;-)
|
+to roll this new version into Chromium." |