diff --git a/src/ahriman/core/build_tools/sources.py b/src/ahriman/core/build_tools/sources.py index 49d0b195..0de21adc 100644 --- a/src/ahriman/core/build_tools/sources.py +++ b/src/ahriman/core/build_tools/sources.py @@ -82,11 +82,11 @@ class Sources(LazyLogging): branch = remote.branch or instance.DEFAULT_BRANCH if is_initialized_git: instance.logger.info("update HEAD to remote at %s using branch %s", sources_dir, branch) - Sources._check_output("git", "fetch", "--quiet", "origin", branch, + Sources._check_output("git", "fetch", "--quiet", "--depth", "1", "origin", branch, cwd=sources_dir, logger=instance.logger) elif remote.git_url is not None: instance.logger.info("clone remote %s to %s using branch %s", remote.git_url, sources_dir, branch) - Sources._check_output("git", "clone", "--quiet", "--branch", branch, "--single-branch", + Sources._check_output("git", "clone", "--quiet", "--depth", "1", "--branch", branch, "--single-branch", remote.git_url, str(sources_dir), cwd=sources_dir.parent, logger=instance.logger) else: # it will cause an exception later diff --git a/tests/ahriman/core/build_tools/test_sources.py b/tests/ahriman/core/build_tools/test_sources.py index 509ee2d5..45f10630 100644 --- a/tests/ahriman/core/build_tools/test_sources.py +++ b/tests/ahriman/core/build_tools/test_sources.py @@ -56,7 +56,8 @@ def test_fetch_existing(remote_source: RemoteSource, mocker: MockerFixture) -> N local = Path("local") Sources.fetch(local, remote_source) check_output_mock.assert_has_calls([ - MockCall("git", "fetch", "--quiet", "origin", remote_source.branch, cwd=local, logger=pytest.helpers.anyvar(int)), + MockCall("git", "fetch", "--quiet", "--depth", "1", "origin", + remote_source.branch, cwd=local, logger=pytest.helpers.anyvar(int)), MockCall("git", "checkout", "--force", remote_source.branch, cwd=local, logger=pytest.helpers.anyvar(int)), MockCall("git", "reset", "--quiet", "--hard", f"origin/{remote_source.branch}", cwd=local, logger=pytest.helpers.anyvar(int)), @@ -75,7 +76,7 @@ def test_fetch_new(remote_source: RemoteSource, mocker: MockerFixture) -> None: local = Path("local") Sources.fetch(local, remote_source) check_output_mock.assert_has_calls([ - MockCall("git", "clone", "--quiet", "--branch", remote_source.branch, "--single-branch", + MockCall("git", "clone", "--quiet", "--depth", "1", "--branch", remote_source.branch, "--single-branch", remote_source.git_url, str(local), cwd=local.parent, logger=pytest.helpers.anyvar(int)), MockCall("git", "checkout", "--force", remote_source.branch, cwd=local, logger=pytest.helpers.anyvar(int)), MockCall("git", "reset", "--quiet", "--hard", f"origin/{remote_source.branch}",