@@ -317,6 +317,54 @@ def test_fetch_default_origin(git2cpp_path, repo_with_remote):
317317 assert p .returncode in [0 , 1 ]
318318
319319
320+ def test_fetch_depth (git2cpp_path , tmp_path , run_in_tmp_path ):
321+ url = "https://github.com/xtensor-stack/xtl.git"
322+ clone_cmd = [git2cpp_path , "clone" , "--depth" , "1" , url ]
323+ p_clone = subprocess .run (clone_cmd , capture_output = True , cwd = tmp_path , text = True )
324+ assert p_clone .returncode == 0
325+ assert (tmp_path / "xtl" ).exists ()
326+
327+ xtl_path = tmp_path / "xtl"
328+
329+ cmd_log = [git2cpp_path , "log" ]
330+ p_log = subprocess .run (cmd_log , capture_output = True , cwd = xtl_path , text = True )
331+ assert p_log .returncode == 0
332+ assert p_log .stdout .count ("Author" ) == 1
333+
334+ depth_cmd = [git2cpp_path , "fetch" , "--depth" , "3" ]
335+ p_depth = subprocess .run (depth_cmd , capture_output = True , cwd = xtl_path , text = True )
336+ assert p_depth .returncode == 0
337+
338+ p_log_2 = subprocess .run (cmd_log , capture_output = True , cwd = xtl_path , text = True )
339+ assert p_log_2 .returncode == 0
340+ assert p_log_2 .stdout .count ("Author" ) > 1
341+
342+
343+ def test_unshallow (git2cpp_path , tmp_path , run_in_tmp_path ):
344+ url = "https://github.com/xtensor-stack/xtl.git"
345+ clone_cmd = [git2cpp_path , "clone" , "--depth" , "1" , url ]
346+ p_clone = subprocess .run (clone_cmd , capture_output = True , cwd = tmp_path , text = True )
347+ assert p_clone .returncode == 0
348+ assert (tmp_path / "xtl" ).exists ()
349+
350+ xtl_path = tmp_path / "xtl"
351+
352+ cmd_log = [git2cpp_path , "log" ]
353+ p_log = subprocess .run (cmd_log , capture_output = True , cwd = xtl_path , text = True )
354+ assert p_log .returncode == 0
355+ assert p_log .stdout .count ("Author" ) == 1
356+
357+ unshallow_cmd = [git2cpp_path , "fetch" , "--unshallow" ]
358+ p_unshallow = subprocess .run (
359+ unshallow_cmd , capture_output = True , cwd = xtl_path , text = True
360+ )
361+ assert p_unshallow .returncode == 0
362+
363+ p_log_2 = subprocess .run (cmd_log , capture_output = True , cwd = xtl_path , text = True )
364+ assert p_log_2 .returncode == 0
365+ assert p_log_2 .stdout .count ("Author" ) > 1
366+
367+
320368def test_remote_in_cloned_repo (xtl_clone , git2cpp_path , tmp_path ):
321369 """Test that cloned repos have remotes configured."""
322370 assert (tmp_path / "xtl" ).exists ()
0 commit comments