| Index: tools/push-to-trunk/common_includes.py
|
| diff --git a/tools/push-to-trunk/common_includes.py b/tools/push-to-trunk/common_includes.py
|
| index 4dfb6d7d279449d7dfcc5c2f1e6dc66562899004..6dbb3f06ebbbc45f66fd73512ba9050449a3f75b 100644
|
| --- a/tools/push-to-trunk/common_includes.py
|
| +++ b/tools/push-to-trunk/common_includes.py
|
| @@ -171,6 +171,16 @@ def MakeChangeLogBugReference(body):
|
| return ""
|
|
|
|
|
| +def SortingKey(version):
|
| + """Key for sorting version number strings: '3.11' > '3.2.1.1'"""
|
| + version_keys = map(int, version.split("."))
|
| + # Fill up to full version numbers to normalize comparison.
|
| + while len(version_keys) < 4: # pragma: no cover
|
| + version_keys.append(0)
|
| + # Fill digits.
|
| + return ".".join(map("{0:04d}".format, version_keys))
|
| +
|
| +
|
| # Some commands don't like the pipe, e.g. calling vi from within the script or
|
| # from subscripts like git cl upload.
|
| def Command(cmd, args="", prefix="", pipe=True):
|
| @@ -369,7 +379,7 @@ class Step(GitRecipesMixin):
|
|
|
| def DeleteBranch(self, name):
|
| for line in self.GitBranch().splitlines():
|
| - if re.match(r".*\s+%s$" % name, line):
|
| + if re.match(r"\*?\s*%s$" % re.escape(name), line):
|
| msg = "Branch %s exists, do you want to delete it?" % name
|
| if self.Confirm(msg):
|
| self.GitDeleteBranch(name)
|
| @@ -467,6 +477,25 @@ class Step(GitRecipesMixin):
|
| return self.GitLog(n=1, format="%H", grep=push_pattern,
|
| parent_hash=parent_hash, branch=branch)
|
|
|
| + def ArrayToVersion(self, prefix):
|
| + return ".".join([self[prefix + "major"],
|
| + self[prefix + "minor"],
|
| + self[prefix + "build"],
|
| + self[prefix + "patch"]])
|
| +
|
| + def SetVersion(self, version_file, prefix):
|
| + output = ""
|
| + for line in FileToText(version_file).splitlines():
|
| + if line.startswith("#define MAJOR_VERSION"):
|
| + line = re.sub("\d+$", self[prefix + "major"], line)
|
| + elif line.startswith("#define MINOR_VERSION"):
|
| + line = re.sub("\d+$", self[prefix + "minor"], line)
|
| + elif line.startswith("#define BUILD_NUMBER"):
|
| + line = re.sub("\d+$", self[prefix + "build"], line)
|
| + elif line.startswith("#define PATCH_LEVEL"):
|
| + line = re.sub("\d+$", self[prefix + "patch"], line)
|
| + output += "%s\n" % line
|
| + TextToFile(output, version_file)
|
|
|
| class UploadStep(Step):
|
| MESSAGE = "Upload for code review."
|
|
|