diff --git a/cachito/workers/scm.py b/cachito/workers/scm.py index 0df31ac2e..4c7013be1 100644 --- a/cachito/workers/scm.py +++ b/cachito/workers/scm.py @@ -158,9 +158,13 @@ def clone_and_archive(self, gitsubmodule=False): self.url, clone_path, no_checkout=True, + # Clone with depth 1 to save resources on large repos + depth=1, # Don't allow git to prompt for a username if we don't have access env={"GIT_TERMINAL_PROMPT": "0"}, ) + + repo.remote().fetch(refspec=self.ref, depth=1) except: # noqa E722 log.exception("Cloning the Git repository from %s failed", self.url) raise CachitoError("Cloning the Git repository failed") @@ -190,7 +194,7 @@ def update_and_archive(self, previous_archive, gitsubmodule=False): try: # The reference must be specified to handle commits which are not part # of a branch. - repo.remote().fetch(refspec=self.ref) + repo.remote().fetch(refspec=self.ref, depth=1) except: # noqa E722 log.exception("Failed to fetch from remote %s", self.url) raise CachitoError("Failed to fetch from the remote Git repository")