| 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 6e821f2a0bff9b8f31c784750227ed517555aa69..a8c131f8c37cd2281473d5fe79401208baf38978 100755
|
| --- a/tools/push-to-trunk/push_to_trunk.py
|
| +++ b/tools/push-to-trunk/push_to_trunk.py
|
| @@ -36,6 +36,7 @@ from common_includes import *
|
|
|
| PUSH_MSG_GIT_SUFFIX = " (based on %s)"
|
| PUSH_MSG_GIT_RE = re.compile(r".* \(based on (?P<git_rev>[a-fA-F0-9]+)\)$")
|
| +VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:\.\d+)?$")
|
|
|
| class Preparation(Step):
|
| MESSAGE = "Preparation."
|
| @@ -44,6 +45,9 @@ class Preparation(Step):
|
| self.InitialEnvironmentChecks(self.default_cwd)
|
| self.CommonPrepare()
|
|
|
| + # Make sure tags are fetched.
|
| + self.Git("fetch origin +refs/tags/*:refs/tags/*")
|
| +
|
| if(self["current_branch"] == self.Config("TRUNKBRANCH")
|
| or self["current_branch"] == self.Config("BRANCHNAME")):
|
| print "Warning: Script started on branch %s" % self["current_branch"]
|
| @@ -109,55 +113,37 @@ class DetectLastPush(Step):
|
| self["last_push_bleeding_edge"] = last_push_bleeding_edge
|
|
|
|
|
| -# TODO(machenbach): Code similarities with bump_up_version.py. Merge after
|
| -# turning this script into a pure git script.
|
| -class GetCurrentBleedingEdgeVersion(Step):
|
| - MESSAGE = "Get latest bleeding edge version."
|
| +class GetLatestVersion(Step):
|
| + MESSAGE = "Get latest version from tags."
|
|
|
| def RunStep(self):
|
| + versions = sorted(filter(VERSION_RE.match, self.vc.GetTags()),
|
| + key=SortingKey, reverse=True)
|
| + self.StoreVersion(versions[0], "latest_")
|
| + self["latest_version"] = self.ArrayToVersion("latest_")
|
| +
|
| + # The version file on master can be used to bump up major/minor at
|
| + # branch time.
|
| self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
|
| + self.ReadAndPersistVersion("master_")
|
| + self["master_version"] = self.ArrayToVersion("master_")
|
|
|
| - # Store latest version.
|
| - self.ReadAndPersistVersion("latest_")
|
| - self["latest_version"] = self.ArrayToVersion("latest_")
|
| - print "Bleeding edge version: %s" % self["latest_version"]
|
| + if SortingKey(self["master_version"]) > SortingKey(self["latest_version"]):
|
| + self["latest_version"] = self["master_version"]
|
| + self.StoreVersion(self["latest_version"], "latest_")
|
| +
|
| + print "Determined latest version %s" % self["latest_version"]
|
|
|
|
|
| class IncrementVersion(Step):
|
| MESSAGE = "Increment version number."
|
|
|
| def RunStep(self):
|
| - # Retrieve current version from last trunk push.
|
| - self.GitCheckoutFile(VERSION_FILE, self["last_push_trunk"])
|
| - self.ReadAndPersistVersion()
|
| - self["trunk_version"] = self.ArrayToVersion("")
|
| -
|
| - if self["latest_build"] == "9999": # pragma: no cover
|
| - # If version control on bleeding edge was switched off, just use the last
|
| - # trunk version.
|
| - self["latest_version"] = self["trunk_version"]
|
| -
|
| - if SortingKey(self["trunk_version"]) < SortingKey(self["latest_version"]):
|
| - # If the version on bleeding_edge is newer than on trunk, use it.
|
| - self.GitCheckoutFile(VERSION_FILE, self.vc.RemoteMasterBranch())
|
| - 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.)" % VERSION_FILE)):
|
| -
|
| - text = FileToText(os.path.join(self.default_cwd, VERSION_FILE))
|
| - text = MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
|
| - r"\g<space>%s" % str(int(self["build"]) + 1),
|
| - text)
|
| - TextToFile(text, os.path.join(self.default_cwd, VERSION_FILE))
|
| - else:
|
| - self.Editor(os.path.join(self.default_cwd, VERSION_FILE))
|
| -
|
| # Variables prefixed with 'new_' contain the new version numbers for the
|
| # ongoing trunk push.
|
| - self.ReadAndPersistVersion("new_")
|
| + self["new_major"] = self["latest_major"]
|
| + self["new_minor"] = self["latest_minor"]
|
| + self["new_build"] = str(int(self["latest_build"]) + 1)
|
|
|
| # Make sure patch level is 0 in a new push.
|
| self["new_patch"] = "0"
|
| @@ -419,7 +405,7 @@ class PushToTrunk(ScriptsBase):
|
| FreshBranch,
|
| PreparePushRevision,
|
| DetectLastPush,
|
| - GetCurrentBleedingEdgeVersion,
|
| + GetLatestVersion,
|
| IncrementVersion,
|
| PrepareChangeLog,
|
| EditChangeLog,
|
|
|