| Index: tools/push-to-trunk/push_to_trunk.py
|
| diff --git a/tools/push-to-trunk/push_to_trunk.py b/tools/push-to-trunk/push_to_trunk.py
|
| index fe4561016abcd8f5bf9d2c2d0c7ae372ccea4b4a..9d17a455315042de22fff6c25bcaf03241429507 100755
|
| --- a/tools/push-to-trunk/push_to_trunk.py
|
| +++ b/tools/push-to-trunk/push_to_trunk.py
|
| @@ -110,6 +110,43 @@ class DetectLastPush(Step):
|
| self["last_push_bleeding_edge"] = last_push_bleeding_edge
|
|
|
|
|
| +class IncrementVersion(Step):
|
| + MESSAGE = "Increment version number."
|
| +
|
| + def RunStep(self):
|
| + # Retrieve current version from last trunk push.
|
| + self.GitCheckoutFile(self.Config(VERSION_FILE), self["last_push_trunk"])
|
| + self.ReadAndPersistVersion()
|
| +
|
| + if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
|
| + "fire up your EDITOR on %s so you can make arbitrary "
|
| + "changes. When you're done, save the file and exit your "
|
| + "EDITOR.)" % self.Config(VERSION_FILE))):
|
| + text = FileToText(self.Config(VERSION_FILE))
|
| + text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
|
| + r"\g<space>%s" % str(int(self["build"]) + 1),
|
| + text)
|
| + TextToFile(text, self.Config(VERSION_FILE))
|
| + else:
|
| + self.Editor(self.Config(VERSION_FILE))
|
| +
|
| + # Variables prefixed with 'new_' contain the new version numbers for the
|
| + # ongoing trunk push.
|
| + self.ReadAndPersistVersion("new_")
|
| + self["version"] = "%s.%s.%s" % (self["new_major"],
|
| + self["new_minor"],
|
| + self["new_build"])
|
| +
|
| + # TODO(machenbach): The following will be deprecated. Increment version
|
| + # numbers for version.cc on bleeding_edge (new build level on trunk + 1).
|
| + text = FileToText(self.Config(VERSION_FILE))
|
| + text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
|
| + r"\g<space>%s" % str(int(self["new_build"]) + 1),
|
| + text)
|
| + TextToFile(text, self.Config(VERSION_FILE))
|
| + self.ReadAndPersistVersion("new_be_")
|
| +
|
| +
|
| class PrepareChangeLog(Step):
|
| MESSAGE = "Prepare raw ChangeLog entry."
|
|
|
| @@ -132,14 +169,8 @@ class PrepareChangeLog(Step):
|
| return body
|
|
|
| def RunStep(self):
|
| - # These version numbers are used again later for the trunk commit.
|
| - self.ReadAndPersistVersion()
|
| self["date"] = self.GetDate()
|
| - self["version"] = "%s.%s.%s" % (self["major"],
|
| - self["minor"],
|
| - self["build"])
|
| - output = "%s: Version %s\n\n" % (self["date"],
|
| - self["version"])
|
| + output = "%s: Version %s\n\n" % (self["date"], self["version"])
|
| TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE))
|
| commits = self.GitLog(format="%H",
|
| git_hash="%s..HEAD" % self["last_push_bleeding_edge"])
|
| @@ -191,35 +222,14 @@ class EditChangeLog(Step):
|
| TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE))
|
|
|
|
|
| -class IncrementVersion(Step):
|
| - MESSAGE = "Increment version number."
|
| -
|
| - def RunStep(self):
|
| - new_build = str(int(self["build"]) + 1)
|
| -
|
| - if self.Confirm(("Automatically increment BUILD_NUMBER? (Saying 'n' will "
|
| - "fire up your EDITOR on %s so you can make arbitrary "
|
| - "changes. When you're done, save the file and exit your "
|
| - "EDITOR.)" % self.Config(VERSION_FILE))):
|
| - text = FileToText(self.Config(VERSION_FILE))
|
| - text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
|
| - r"\g<space>%s" % new_build,
|
| - text)
|
| - TextToFile(text, self.Config(VERSION_FILE))
|
| - else:
|
| - self.Editor(self.Config(VERSION_FILE))
|
| -
|
| - self.ReadAndPersistVersion("new_")
|
| -
|
| -
|
| class CommitLocal(Step):
|
| MESSAGE = "Commit to local branch."
|
|
|
| def RunStep(self):
|
| self["prep_commit_msg"] = ("Prepare push to trunk. "
|
| - "Now working on version %s.%s.%s." % (self["new_major"],
|
| - self["new_minor"],
|
| - self["new_build"]))
|
| + "Now working on version %s.%s.%s." % (self["new_be_major"],
|
| + self["new_be_minor"],
|
| + self["new_be_build"]))
|
|
|
| # Include optional TBR only in the git command. The persisted commit
|
| # message is used for finding the commit again later.
|
| @@ -329,11 +339,11 @@ class SetVersion(Step):
|
| output = ""
|
| for line in FileToText(self.Config(VERSION_FILE)).splitlines():
|
| if line.startswith("#define MAJOR_VERSION"):
|
| - line = re.sub("\d+$", self["major"], line)
|
| + line = re.sub("\d+$", self["new_major"], line)
|
| elif line.startswith("#define MINOR_VERSION"):
|
| - line = re.sub("\d+$", self["minor"], line)
|
| + line = re.sub("\d+$", self["new_minor"], line)
|
| elif line.startswith("#define BUILD_NUMBER"):
|
| - line = re.sub("\d+$", self["build"], line)
|
| + line = re.sub("\d+$", self["new_build"], line)
|
| elif line.startswith("#define PATCH_LEVEL"):
|
| line = re.sub("\d+$", "0", line)
|
| elif line.startswith("#define IS_CANDIDATE_VERSION"):
|
| @@ -529,9 +539,9 @@ class PushToTrunk(ScriptsBase):
|
| Preparation,
|
| FreshBranch,
|
| DetectLastPush,
|
| + IncrementVersion,
|
| PrepareChangeLog,
|
| EditChangeLog,
|
| - IncrementVersion,
|
| CommitLocal,
|
| UploadStep,
|
| CommitRepository,
|
|
|