diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2015-04-15 12:17:16 +0000 |
---|---|---|
committer | Morph (on behalf of Adam Coldrick) <adam.coldrick@codethink.co.uk> | 2015-04-15 12:17:16 +0000 |
commit | 85995d210162d1432800acf357f8162b77f5b47e (patch) | |
tree | 256ba048782865a8d9b52e497ff0ea5f694d652b /morphlib/gitdir.py | |
parent | 3167ced4844c9602e88289607d1c2cc2ecbd5d95 (diff) | |
download | morph-85995d210162d1432800acf357f8162b77f5b47e.tar.gz |
Morph build c3874f415dc6448ca28d9a01edab0948baserock/6453f312359f4317803ef7f14b58d21f/d675b946df4f456693ed211dcd2ec95e
System branch: master
Diffstat (limited to 'morphlib/gitdir.py')
-rw-r--r-- | morphlib/gitdir.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index 03640a22..1c286720 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -681,6 +681,32 @@ class GitDirectory(object): if not morphlib.git.is_valid_sha1(string): raise ExpectedSha1Error(string) + def _check_ref_exists(self, ref): + self._rev_parse('%s^{commit}' % ref) + + def _gitcmd_output_list(self, *args): + output = morphlib.git.gitcmd(self._runcmd, *args) + separated = [l.strip() for l in output.splitlines()] + prefix = '* ' + for i, l in enumerate(separated): + if l.startswith(prefix): + separated[i] = l[len(prefix):] + return separated + + def tags_containing_sha1(self, ref): # pragma: no cover + self._check_is_sha1(ref) + self._check_ref_exists(ref) + + args = ['tag', '--contains', ref] + return self._gitcmd_output_list(*args) + + def branches_containing_sha1(self, ref): + self._check_is_sha1(ref) + self._check_ref_exists(ref) + + 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, |