File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def get_clone_url(self) -> str:
4343 def clone (self , branch : str | None = None ) -> None :
4444 self .__delete_tmp_dir ()
4545 self .__tmp_dir = create_tmp_dir ()
46- git_options = []
46+ git_options = ["--depth=1" ]
4747 url = self .get_clone_url ()
4848 if branch :
4949 logging .info ("Cloning repository: %s (branch: %s)" , url , branch )
Original file line number Diff line number Diff line change @@ -166,6 +166,16 @@ def test_clone_unknown_url(self, logging_mock):
166166 self .assertEqual ("Error cloning 'invalid_url'" , str (ex .value ))
167167 logging_mock .info .assert_called_once_with ("Cloning repository: %s" , self .__mock_repo_api .get_clone_url ())
168168
169+ def test_clone_with_depth_1 (self ):
170+ with GitRepo (self .__mock_repo_api ) as testee :
171+ testee .clone ()
172+
173+ # Verify that the repository was cloned with depth 1
174+ repo = Repo (testee .get_full_file_path ("." ))
175+ # A shallow clone with depth 1 should only have the latest commit
176+ commits = list (repo .iter_commits ("master" ))
177+ self .assertEqual (1 , len (commits ), "Clone should be shallow with depth 1" )
178+
169179 def test_get_full_file_path (self ):
170180 with GitRepo (self .__mock_repo_api ) as testee :
171181 testee .clone ()
You can’t perform that action at this time.
0 commit comments