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 f015601a070b652b816dfe5e9e0f6814306a0cc6..b8d1620dbda0cf9868dd47ada80e78add574ab83 100644 |
--- a/tools/push-to-trunk/common_includes.py |
+++ b/tools/push-to-trunk/common_includes.py |
@@ -296,6 +296,10 @@ class VCInterface(object): |
# tag and commit are different remote commands, while in git we would commit |
# and tag locally and then push/land in one unique step. |
def Tag(self, tag, remote): |
+ """Sets a tag for the current commit. |
+ |
+ Assumptions: The commit already landed and the commit message is unique. |
+ """ |
raise NotImplementedError() |
@@ -348,7 +352,7 @@ class GitSvnInterface(VCInterface): |
self.step.GitSVNTag(tag) |
-class GitReadOnlyMixin(VCInterface): |
+class GitTagsOnlyMixin(VCInterface): |
def Pull(self): |
self.step.GitPull() |
@@ -377,8 +381,33 @@ class GitReadOnlyMixin(VCInterface): |
return "origin/%s" % name |
return "origin/branch-heads/%s" % name |
- |
-class GitReadSvnWriteInterface(GitReadOnlyMixin, GitSvnInterface): |
+ def Tag(self, tag, remote): |
+ # Title of the current commit (the local title and the title for committing |
+ # is the same in all merge and push scripts). |
+ title = self.step.GitLog(n=1, format="%s") |
+ |
+ # Wait for the commit to appear. Assumes unique commit message titles (this |
+ # is the case for all automated merge and push commits - also no title is |
+ # the prefix of another title). |
+ commit = None |
+ for wait_interval in [3, 5, 10, 30]: |
tandrii(chromium)
2014/10/02 17:36:06
not sure 48 seconds is enough, you probably know b
Michael Achenbach
2014/10/07 10:10:50
Bumped it a little.
|
+ self.step.Git("fetch") |
+ commit = self.step.GitLog(n=1, format="%H", grep=title, branch=remote) |
+ if commit: |
tandrii(chromium)
2014/10/02 17:36:06
Naturally, i'm not sure about assumption above the
Michael Achenbach
2014/10/07 10:10:50
I don't need the assumption if I add the commit me
|
+ break |
+ print("The commit has not replicated to git. Waiting for %s seconds." % |
+ wait_interval) |
+ self.step._side_effect_handler.Sleep(wait_interval) |
+ |
+ if not commit: |
tandrii(chromium)
2014/10/02 17:36:06
or just
else:
Michael Achenbach
2014/10/07 10:10:50
Odd construct - but I love shorter code :)
|
+ self.step.Die("Couldn't determine commit for setting the tag. Maybe the " |
+ "git updater is lagging behind?") |
+ |
+ self.step.Git("tag %s %s" % (tag, commit)) |
+ self.step.Git("push origin %s" % tag) |
+ |
+ |
+class GitReadSvnWriteInterface(GitTagsOnlyMixin, GitSvnInterface): |
pass |