Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gitopscli/git_api/git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_clone_url(self) -> str:
def clone(self, branch: str | None = None) -> None:
self.__delete_tmp_dir()
self.__tmp_dir = create_tmp_dir()
git_options = []
git_options = ["--depth=1"]
url = self.get_clone_url()
if branch:
logging.info("Cloning repository: %s (branch: %s)", url, branch)
Expand Down
10 changes: 10 additions & 0 deletions tests/git_api/test_git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ def test_clone_unknown_url(self, logging_mock):
self.assertEqual("Error cloning 'invalid_url'", str(ex.value))
logging_mock.info.assert_called_once_with("Cloning repository: %s", self.__mock_repo_api.get_clone_url())

def test_clone_with_depth_1(self):
with GitRepo(self.__mock_repo_api) as testee:
testee.clone()

# Verify that the repository was cloned with depth 1
repo = Repo(testee.get_full_file_path("."))
# A shallow clone with depth 1 should only have the latest commit
commits = list(repo.iter_commits("master"))
self.assertEqual(1, len(commits), "Clone should be shallow with depth 1")

def test_get_full_file_path(self):
with GitRepo(self.__mock_repo_api) as testee:
testee.clone()
Expand Down