summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-07-11 14:17:41 -0700
committerGitHub <noreply@github.com>2016-07-11 14:17:41 -0700
commit78ac11ff8892c859489e3b9c7c5efb17749e1bc8 (patch)
tree739126c69e7dbf50adbe8b6ad053bb6a26da3b07
parentefdcd199c153dfbf7e21cbc0010cffe5eef7d327 (diff)
parent283d621b6e6016b57d12fba11db5f3be9b473204 (diff)
downloadspack-78ac11ff8892c859489e3b9c7c5efb17749e1bc8.tar.gz
spack-78ac11ff8892c859489e3b9c7c5efb17749e1bc8.tar.bz2
spack-78ac11ff8892c859489e3b9c7c5efb17749e1bc8.tar.xz
spack-78ac11ff8892c859489e3b9c7c5efb17749e1bc8.zip
Merge pull request #1217 from LLNL/features/git-submodule-init
Add `submodules` option for git fetching.
-rw-r--r--lib/spack/docs/packaging_guide.rst12
-rw-r--r--lib/spack/spack/fetch_strategy.py9
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index e616581ca4..0f549e2957 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -604,6 +604,7 @@ Git fetching is enabled with the following parameters to ``version``:
* ``tag``: name of a tag to fetch.
* ``branch``: name of a branch to fetch.
* ``commit``: SHA hash (or prefix) of a commit to fetch.
+ * ``submodules``: Also fetch submodules when checking out this repository.
Only one of ``tag``, ``branch``, or ``commit`` can be used at a time.
@@ -660,6 +661,17 @@ Commits
could just use the abbreviated commit hash. It's up to the package
author to decide what makes the most sense.
+Submodules
+
+ You can supply ``submodules=True`` to cause Spack to fetch submodules
+ along with the repository at fetch time.
+
+ .. code-block:: python
+
+ version('1.0.1', git='https://github.com/example-project/example.git',
+ tag='v1.0.1', submdoules=True)
+
+
Installing
^^^^^^^^^^^^^^
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 38133ee0ca..bcb33bd0e6 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -366,8 +366,8 @@ class CacheURLFetchStrategy(URLFetchStrategy):
try:
self.check()
except ChecksumError:
- # Future fetchers will assume they don't need to download if the
- # file remains
+ # Future fetchers will assume they don't need to
+ # download if the file remains
os.remove(self.archive_file)
raise
@@ -517,6 +517,7 @@ class GitFetchStrategy(VCSFetchStrategy):
super(GitFetchStrategy, self).__init__(
'git', 'tag', 'branch', 'commit', **forwarded_args)
self._git = None
+ self.submodules = kwargs.get('submodules', False)
@property
def git_version(self):
@@ -595,6 +596,10 @@ class GitFetchStrategy(VCSFetchStrategy):
self.git('pull', '--tags', ignore_errors=1)
self.git('checkout', self.tag)
+ # Init submodules if the user asked for them.
+ if self.submodules:
+ self.git('submodule', 'update', '--init')
+
def archive(self, destination):
super(GitFetchStrategy, self).archive(destination, exclude='.git')