Index: tools/push-to-trunk/git_recipes.py |
diff --git a/tools/push-to-trunk/git_recipes.py b/tools/push-to-trunk/git_recipes.py |
index a1e6256df29db1b26e7ea5676f584c72700e39d5..8944f7ca092d80b06451f358e8f2df2f8165f599 100644 |
--- a/tools/push-to-trunk/git_recipes.py |
+++ b/tools/push-to-trunk/git_recipes.py |
@@ -101,6 +101,18 @@ class GitRecipesMixin(object): |
def GitBranch(self, **kwargs): |
return self.Git("branch", **kwargs) |
+ @Strip |
+ def GitRemoteContains(self, hsh, **kwargs): |
agable
2014/09/29 09:49:12
I'd be scared that someone might use this who does
Michael Achenbach
2014/09/29 10:46:25
I'll rename the function as it should be just used
|
+ """Returns the remote branch for a given commit. |
+ |
+ Returns an empty string in case the commit doesn't exist on any remote |
agable
2014/09/29 09:49:11
None is a better sentinel value than "".
Michael Achenbach
2014/09/29 10:46:25
Done. Was because of the @Strip wrapper. But I mak
|
+ branch. |
+ Returns the last remote branch in case the commit exists on more than one. |
+ """ |
+ branches = self.Git(MakeArgs(["branch -r --contains", hsh]), |
+ **kwargs).strip().splitlines() |
+ return (branches or [""])[-1] |
+ |
def GitCreateBranch(self, name, branch="", **kwargs): |
assert name |
self.Git(MakeArgs(["checkout -b", name, branch]), **kwargs) |