diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-11-20 13:57:31 +0000 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-11-20 14:09:18 +0000 |
commit | d5b0d37ad9343b8d66fe99648d305a41199d3920 (patch) | |
tree | db3966aca61264e2ef2635bace6c4667bbd21abb /morphlib/gitdir.py | |
parent | a75e5121478e2a645c65d276cc20f3eb659222f4 (diff) | |
download | morph-baserock/tiagogomes/multiple-sources.tar.gz |
WIP Add support for multiple sources per chunkbaserock/tiagogomes/multiple-sources
TODO:
- Add API to the cache server to retrieve a submodule commit from a
given path.
- Fix cross-bootstrap command.
Change-Id: I3475c2bcb648a272fee33bc878a521f79d4e6581
Diffstat (limited to 'morphlib/gitdir.py')
-rw-r--r-- | morphlib/gitdir.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index d1770275..a4e51e30 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -53,6 +53,14 @@ class ExpectedSha1Error(cliapp.AppException): self, 'SHA1 expected, got %s' % ref) +class MissingSubmoduleCommitError(cliapp.AppException): + + def __init__(self, repo, ref, submodule): + cliapp.AppException.__init__(self, # pragma + '%s:%s:.gitmodules: No commit object found for ' + 'submodule "%s"' % (repo, ref, submodule)) + + class RefChangeError(cliapp.AppException): pass @@ -861,6 +869,20 @@ class GitDirectory(object): except Exception as e: raise RefDeleteError(self, ref, old_sha1, e) + def get_submodule_commit(self, parent_ref, + submodule_path): # pragma: no cover + try: + lstree_output = morphlib.git.gitcmd(self._runcmd, 'ls-tree', + parent_ref, submodule_path) + except cliapp.AppException: + raise MissingSubmoduleCommitError(self.dirname, parent_ref, + submodule_path) + m = re.match("160000 commit (?P<sha1>\w{40})", lstree_output) + if not m: + raise MissingSubmoduleCommitError(self.dirname, parent_ref, + submodule_path) + return m.group('sha1') + def describe(self): version = morphlib.git.gitcmd(self._runcmd, 'describe', '--always', '--dirty=-unreproducible') |