Chromium Code Reviews| 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): |
|
Michael Achenbach
2014/07/15 13:30:34
Refactoring: Copied from releases.py.
|
| + """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): |
|
Michael Achenbach
2014/07/15 13:30:34
Bugfix: The output of GitBranch is stripped. The o
|
| 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): |
|
Michael Achenbach
2014/07/15 13:30:34
Refactoring: Copied from push_to_trunk.py.
|
| + 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." |