Repository: easybuilders/easybuild-framework

Issue:
error: pathspec ... did not match any file(s) known to git
The error seen in https://github.com/easybuilders/easybuild-easyconfigs/issues/14200 is seen for a bunch of other easyconfigs. This suggests we are using the wrong method to checkout git repositories for a specific commit.

Using eb --fetch --force-download --sourcepath /tmp/test [ec].

Failures:

- Dalton-2020.0-foss-2021a.eb: error: pathspec 'refs/tags/release/2016' did not match any file(s) known to git
- GenomeWorks-2021.02.2-fosscuda-2020b.eb: error: pathspec '691380d' did not match any file(s) known to git
- OpenFOAM-Extend-4.1-20191120-intel-2019b-Python-2.7.16.eb: error: pathspec '93ffff' did not match any file(s) known to git
- OpenFOAM-Extend-4.1-20200408-foss-2019b-Python-2.7.16.eb: error: pathspec 'f2c557' did not match any file(s) known to git
- PHANOTATE-20190724-foss-2018b.eb: error: pathspec 'cc42101' did not match any file(s) known to git
- Sambamba-0.8.0-GCC-10.2.0.eb: error: pathspec 'cdc5f84' did not match any file(s) known to git
- SeisSol-201703-foss-2018b-Python-2.7.15.eb: error: pathspec 'fb97bef' did not match any file(s) known to git
- SeuratWrappers-20210528-foss-2020b-R-4.0.3.eb: error: pathspec '7b9818d' did not match any file(s) known to git
- XGBoost-20171120-intel-2017b-Java-1.8.0_152.eb: error: pathspec '8817769' did not match any file(s) known to git

Successes:

- NewHybrids-1.1_Beta3-GCC-10.2.0.eb
- PyTorch 1.8.1 and 1.9.0
- RAxML-NG-1.0.3-GCC-10.2.0.eb
- SeuratData-20210514-foss-2020b-R-4.0.3.eb


Discussion:

Resolving patch:
diff --git a/easybuild/tools/filetools.py b/easybuild/tools/filetools.py
--- a/easybuild/tools/filetools.py
+++ b/easybuild/tools/filetools.py
@@ -2598,7 +2598,7 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
     # compose 'git clone' command, and run it
     clone_cmd = ['git', 'clone']
 
-    if not keep_git_dir:
+    if not keep_git_dir and not commit:
         # Speed up cloning by only fetching the most recent commit, not the whole history
         # When we don't want to keep the .git folder there won't be a difference in the result
         clone_cmd.extend(['--depth', '1'])


Test patch:
diff --git a/test/framework/filetools.py b/test/framework/filetools.py
--- a/test/framework/filetools.py
+++ b/test/framework/filetools.py
@@ -2750,7 +2750,7 @@ def run_check():
         del git_config['tag']
         git_config['commit'] = '8456f86'
         expected = '\n'.join([
-            r'  running command "git clone --depth 1 --no-checkout %(git_repo)s"',
+            r'  running command "git clone --no-checkout %(git_repo)s"',
             r"  \(in .*/tmp.*\)",
             r'  running command "git checkout 8456f86 && git submodule update --init --recursive"',
             r"  \(in testrepository\)",
@@ -2761,7 +2761,7 @@ def run_check():
 
         del git_config['recursive']
         expected = '\n'.join([
-            r'  running command "git clone --depth 1 --no-checkout %(git_repo)s"',
+            r'  running command "git clone --no-checkout %(git_repo)s"',
             r"  \(in .*/tmp.*\)",
             r'  running command "git checkout 8456f86"',
             r"  \(in testrepository\)",