From 72d106b681ebaf113c017a4c59e999de0bead319 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 18 Mar 2015 18:13:51 +0000 Subject: Add functions for checking which tags/branches contain a ref Change-Id: Ic6e613c21ed26c528ad7c75f41af01d7552729fd --- morphlib/gitdir.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index 03640a22..80d3bcb5 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -681,6 +681,23 @@ class GitDirectory(object): if not morphlib.git.is_valid_sha1(string): raise ExpectedSha1Error(string) + def _gitcmd_output_list(self, *args): # pragma: no cover + output = None + try: + output = morphlib.git.gitcmd(self._runcmd, *args) + except Exception, e: + raise e + + return [l.strip() for l in output.splitlines()] + + def tags_containing_ref(self, ref): # pragma: no cover + args = ['tag', '--contains', ref] + return self._gitcmd_output_list(*args) + + def branches_containing_ref(self, ref): # pragma: no cover + args = ['branch', '--contains', ref] + return self._gitcmd_output_list(*args) + def _update_ref(self, ref_args, message): args = ['update-ref'] # No test coverage, since while this functionality is useful, -- cgit v1.2.1