Skip to content

Commit

Permalink
Use the filter option of clone to avoid cloning everything
Browse files Browse the repository at this point in the history
It gives references to commits and it's possible to fetch the blob
needed.
  • Loading branch information
aurianer committed Nov 11, 2024
1 parent 4ce4885 commit d49e512
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion stackinator/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def generate(self, recipe):

# clone the repository
capture = subprocess.run(
["git", "clone", spack["repo"], spack_path],
["git", "clone", "--filter=tree:0", spack["repo"], spack_path],
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand All @@ -200,6 +200,21 @@ def generate(self, recipe):
self._logger.error(f'error cloning the repository {spack["repo"]}')
capture.check_returncode()

# Fetch the specific branch
if spack["commit"]:
self._logger.info(f'spack: fetch branch/commit {spack["commit"]}')
capture = subprocess.run(
["git", "-C", spack_path, "fetch", "origin", spack["commit"]],
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
self._logger.debug(capture.stdout.decode("utf-8"))

if capture.returncode != 0:
self._logger.debug(f'unable to change to the fetch {spack["commit"]}')
capture.check_returncode()

# Check out a branch or commit if one was specified
if spack["commit"]:
self._logger.info(f'spack: checkout branch/commit {spack["commit"]}')
Expand Down

0 comments on commit d49e512

Please sign in to comment.