diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-02-09 18:07:06 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-02-09 18:07:53 +0000 |
commit | 7516ac07e29cb6c2f2da445ea08aae176669e92e (patch) | |
tree | 9cf11d17cc7dc5532ae111ac87dc7338fb458634 | |
parent | 46315658bb72f6d4915aa5b23c54a553882180d7 (diff) | |
download | morph-7516ac07e29cb6c2f2da445ea08aae176669e92e.tar.gz |
Add --ignore-submodules flag to avoid updating/unpacking submodules.
-rwxr-xr-x | morph | 4 | ||||
-rw-r--r-- | morphlib/sourcemanager.py | 17 | ||||
-rw-r--r-- | morphlib/sourcemanager_tests.py | 1 |
3 files changed, 15 insertions, 7 deletions
@@ -58,6 +58,10 @@ class Morph(cliapp.Application): 'build stuff in bootstrap mode; this is ' 'DANGEROUS and will install stuff on your ' 'system') + self.settings.boolean(['ignore-submodules'], + 'do not cache repositories of submodules and ' + 'unpack them into the build directory', + default=True) self.settings.boolean(['test-console'], 'show what the system outputs on the serial ' diff --git a/morphlib/sourcemanager.py b/morphlib/sourcemanager.py index a1482bd7..cc0efe64 100644 --- a/morphlib/sourcemanager.py +++ b/morphlib/sourcemanager.py @@ -70,7 +70,7 @@ class SourceManager(object): location = self.cache_dir + '/' + name if os.path.exists(location): - if self.update: + if self.update: # pragma: no cover self.msg('Cached clone exists, updating origin') try: morphlib.git.update_remote(location, "origin", self.msg) @@ -78,7 +78,7 @@ class SourceManager(object): logging.warning('Ignoring git error:\n%s' % str(e)) else: # pragma: no cover self.msg('Cached clone exists, assuming origin is up to date') - return True, location + return True, location # pragma: no cover else: self.msg('No cached clone found, fetching from %s' % repo) @@ -169,7 +169,7 @@ class SourceManager(object): else: raise RepositoryUpdateError(repo, ref) - def _resolve_submodules(self, treeish): + def _resolve_submodules(self, treeish): # pragma: no cover self.indent_more() # resolve submodules @@ -201,15 +201,18 @@ class SourceManager(object): ''' - if (repo, ref) not in self.cached_treeishes: + if (repo, ref) not in self.cached_treeishes: # pragma: no cover # load the corresponding treeish on demand treeish = self._cache_git_from_base_urls(repo, ref) # have a treeish now, cache it to avoid loading it twice self.cached_treeishes[(repo, ref)] = treeish - # load tree-ishes for submodules, if necessary - self._resolve_submodules(treeish) + # load tree-ishes for submodules, if necessary and desired + if self.settings['ignore-submodules']: + treeish.submodules = [] + else: + self._resolve_submodules(treeish) # we should now have a cached treeish to use now - return self.cached_treeishes[(repo, ref)] + return self.cached_treeishes[(repo, ref)] # pragma: no cover diff --git a/morphlib/sourcemanager_tests.py b/morphlib/sourcemanager_tests.py index 97ef7ed5..98cc0305 100644 --- a/morphlib/sourcemanager_tests.py +++ b/morphlib/sourcemanager_tests.py @@ -31,6 +31,7 @@ class DummyApp(object): 'git-base-url': ['.',], 'bundle-server': None, 'cachedir': '/foo/bar/baz', + 'ignore-submodules': False } self.msg = lambda msg: None |