os.remove(self.Config("PATCH_FILE"))
+class CommitSquash(Step):
+ MESSAGE = "Commit to local candidates branch."
+
+ def RunStep(self):
+ # Make a first commit with a slightly different title to not confuse
+ # the tagging.
+ msg = FileToText(self.Config("COMMITMSG_FILE")).splitlines()
+ msg[0] = msg[0].replace("(based on", "(squashed - based on")
+ self.GitCommit(message = "\n".join(msg))
+
+
+class PrepareVersionBranch(Step):
+ MESSAGE = "Prepare new branch to commit version and changelog file."
+
+ def RunStep(self):
+ self.GitCheckout("master")
+ self.Git("fetch")
+ self.GitDeleteBranch(self.Config("TRUNKBRANCH"))
+ self.GitCreateBranch(self.Config("TRUNKBRANCH"),
+ self.vc.RemoteCandidateBranch())
+
+
class AddChangeLog(Step):
MESSAGE = "Add ChangeLog changes to trunk branch."
self.SetVersion(os.path.join(self.default_cwd, VERSION_FILE), "new_")
-class CommitTrunk(Step):
- MESSAGE = "Commit to local trunk branch."
+class CommitCandidate(Step):
+ MESSAGE = "Commit version and changelog to local candidates branch."
def RunStep(self):
self.GitCommit(file_name = self.Config("COMMITMSG_FILE"))
SquashCommits,
NewBranch,
ApplyChanges,
+ CommitSquash,
+ SanityCheck,
+ Land,
+ PrepareVersionBranch,
AddChangeLog,
SetVersion,
- CommitTrunk,
- SanityCheck,
+ CommitCandidate,
Land,
TagRevision,
CleanUp,
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
os.environ["EDITOR"] = "vi"
+ commit_msg_squashed = """Version 3.22.5 (squashed - based on push_hash)
+
+Log text 1 (issue 321).
+
+Performance and stability improvements on all platforms."""
+
+ commit_msg = """Version 3.22.5 (based on push_hash)
+
+Log text 1 (issue 321).
+
+Performance and stability improvements on all platforms."""
+
def ResetChangeLog():
"""On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog',
the ChangLog will be reset to its content on trunk."""
ResetChangeLog()
self.WriteFakeVersionFile()
- def CheckSVNCommit():
+ def CheckVersionCommit():
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
- self.assertEquals(
-"""Version 3.22.5 (based on push_hash)
-
-Log text 1 (issue 321).
-
-Performance and stability improvements on all platforms.""", commit)
+ self.assertEquals(commit_msg, commit)
version = FileToText(
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
Cmd(("git new-branch %s --upstream origin/candidates" %
TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk),
Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
+ Cmd("git commit -am \"%s\"" % commit_msg_squashed, ""),
+ ]
+ if manual:
+ expectations.append(RL("Y")) # Sanity check.
+ expectations += [
+ Cmd("git cl land -f --bypass-hooks", ""),
+ Cmd("git checkout -f master", ""),
+ Cmd("git fetch", ""),
+ Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""),
+ Cmd(("git new-branch %s --upstream origin/candidates" %
+ TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk),
Cmd("git checkout -f origin/candidates -- ChangeLog", "",
cb=ResetChangeLog),
Cmd("git checkout -f origin/candidates -- src/version.cc", "",
cb=self.WriteFakeVersionFile),
Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
- cb=CheckSVNCommit),
- ]
- if manual:
- expectations.append(RL("Y")) # Sanity check.
- expectations += [
+ cb=CheckVersionCommit),
Cmd("git cl land -f --bypass-hooks", ""),
Cmd("git fetch", ""),
Cmd("git log -1 --format=%H --grep="