1212
1313import pytest
1414
15- from gitingest .cloning import CloneConfig , _check_repo_exists , clone_repo
15+ from gitingest .cloning import CloneConfig , _check_repo_exists , clone
1616from gitingest .exceptions import AsyncTimeoutError
1717
1818
1919@pytest .mark .asyncio
20- async def test_clone_repo_with_commit () -> None :
20+ async def test_clone_with_commit () -> None :
2121 """
2222 Test cloning a repository with a specific commit hash.
2323
2424 Given a valid URL and a commit hash:
25- When `clone_repo ` is called,
25+ When `clone ` is called,
2626 Then the repository should be cloned and checked out at that commit.
2727 """
2828 clone_config = CloneConfig (
@@ -38,19 +38,19 @@ async def test_clone_repo_with_commit() -> None:
3838 mock_process .communicate .return_value = (b"output" , b"error" )
3939 mock_exec .return_value = mock_process
4040
41- await clone_repo (clone_config )
41+ await clone (clone_config )
4242
4343 mock_check .assert_called_once_with (clone_config .url )
4444 assert mock_exec .call_count == 2 # Clone and checkout calls
4545
4646
4747@pytest .mark .asyncio
48- async def test_clone_repo_without_commit () -> None :
48+ async def test_clone_without_commit () -> None :
4949 """
5050 Test cloning a repository when no commit hash is provided.
5151
5252 Given a valid URL and no commit hash:
53- When `clone_repo ` is called,
53+ When `clone ` is called,
5454 Then only the clone operation should be performed (no checkout).
5555 """
5656 query = CloneConfig (
@@ -66,19 +66,19 @@ async def test_clone_repo_without_commit() -> None:
6666 mock_process .communicate .return_value = (b"output" , b"error" )
6767 mock_exec .return_value = mock_process
6868
69- await clone_repo (query )
69+ await clone (query )
7070
7171 mock_check .assert_called_once_with (query .url )
7272 assert mock_exec .call_count == 1 # Only clone call
7373
7474
7575@pytest .mark .asyncio
76- async def test_clone_repo_nonexistent_repository () -> None :
76+ async def test_clone_nonexistent_repository () -> None :
7777 """
7878 Test cloning a nonexistent repository URL.
7979
8080 Given an invalid or nonexistent URL:
81- When `clone_repo ` is called,
81+ When `clone ` is called,
8282 Then a ValueError should be raised with an appropriate error message.
8383 """
8484 clone_config = CloneConfig (
@@ -89,7 +89,7 @@ async def test_clone_repo_nonexistent_repository() -> None:
8989 )
9090 with patch ("gitingest.cloning._check_repo_exists" , return_value = False ) as mock_check :
9191 with pytest .raises (ValueError , match = "Repository not found" ):
92- await clone_repo (clone_config )
92+ await clone (clone_config )
9393
9494 mock_check .assert_called_once_with (clone_config .url )
9595
@@ -126,18 +126,18 @@ async def test_check_repo_exists(mock_stdout: bytes, return_code: int, expected:
126126
127127
128128@pytest .mark .asyncio
129- async def test_clone_repo_with_custom_branch () -> None :
129+ async def test_clone_with_custom_branch () -> None :
130130 """
131131 Test cloning a repository with a specified custom branch.
132132
133133 Given a valid URL and a branch:
134- When `clone_repo ` is called,
134+ When `clone ` is called,
135135 Then the repository should be cloned shallowly to that branch.
136136 """
137137 clone_config = CloneConfig (url = "https://github.com/user/repo" , local_path = "/tmp/repo" , branch = "feature-branch" )
138138 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
139139 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
140- await clone_repo (clone_config )
140+ await clone (clone_config )
141141
142142 mock_exec .assert_called_once_with (
143143 "git" ,
@@ -157,7 +157,7 @@ async def test_git_command_failure() -> None:
157157 Test cloning when the Git command fails during execution.
158158
159159 Given a valid URL, but `_run_command` raises a RuntimeError:
160- When `clone_repo ` is called,
160+ When `clone ` is called,
161161 Then a RuntimeError should be raised with the correct message.
162162 """
163163 clone_config = CloneConfig (
@@ -167,16 +167,16 @@ async def test_git_command_failure() -> None:
167167 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
168168 with patch ("gitingest.cloning._run_command" , side_effect = RuntimeError ("Git command failed" )):
169169 with pytest .raises (RuntimeError , match = "Git command failed" ):
170- await clone_repo (clone_config )
170+ await clone (clone_config )
171171
172172
173173@pytest .mark .asyncio
174- async def test_clone_repo_default_shallow_clone () -> None :
174+ async def test_clone_default_shallow_clone () -> None :
175175 """
176176 Test cloning a repository with the default shallow clone options.
177177
178178 Given a valid URL and no branch or commit:
179- When `clone_repo ` is called,
179+ When `clone ` is called,
180180 Then the repository should be cloned with `--depth=1` and `--single-branch`.
181181 """
182182 clone_config = CloneConfig (
@@ -186,7 +186,7 @@ async def test_clone_repo_default_shallow_clone() -> None:
186186
187187 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
188188 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
189- await clone_repo (clone_config )
189+ await clone (clone_config )
190190
191191 mock_exec .assert_called_once_with (
192192 "git" ,
@@ -199,12 +199,12 @@ async def test_clone_repo_default_shallow_clone() -> None:
199199
200200
201201@pytest .mark .asyncio
202- async def test_clone_repo_commit_without_branch () -> None :
202+ async def test_clone_commit_without_branch () -> None :
203203 """
204204 Test cloning when a commit hash is provided but no branch is specified.
205205
206206 Given a valid URL and a commit hash (but no branch):
207- When `clone_repo ` is called,
207+ When `clone ` is called,
208208 Then the repository should be cloned and checked out at that commit.
209209 """
210210 clone_config = CloneConfig (
@@ -214,7 +214,7 @@ async def test_clone_repo_commit_without_branch() -> None:
214214 )
215215 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
216216 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
217- await clone_repo (clone_config )
217+ await clone (clone_config )
218218
219219 assert mock_exec .call_count == 2 # Clone and checkout calls
220220 mock_exec .assert_any_call ("git" , "clone" , "--single-branch" , clone_config .url , clone_config .local_path )
@@ -264,12 +264,12 @@ async def test_check_repo_exists_with_permanent_redirect() -> None:
264264
265265
266266@pytest .mark .asyncio
267- async def test_clone_repo_with_timeout () -> None :
267+ async def test_clone_with_timeout () -> None :
268268 """
269269 Test cloning a repository when a timeout occurs.
270270
271271 Given a valid URL, but `_run_command` times out:
272- When `clone_repo ` is called,
272+ When `clone ` is called,
273273 Then an `AsyncTimeoutError` should be raised to indicate the operation exceeded time limits.
274274 """
275275 clone_config = CloneConfig (url = "https://github.com/user/repo" , local_path = "/tmp/repo" )
@@ -278,7 +278,7 @@ async def test_clone_repo_with_timeout() -> None:
278278 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
279279 mock_exec .side_effect = asyncio .TimeoutError
280280 with pytest .raises (AsyncTimeoutError , match = "Operation timed out after" ):
281- await clone_repo (clone_config )
281+ await clone (clone_config )
282282
283283
284284@pytest .mark .asyncio
@@ -287,15 +287,15 @@ async def test_clone_specific_branch(tmp_path):
287287 Test cloning a specific branch of a repository.
288288
289289 Given a valid repository URL and a branch name:
290- When `clone_repo ` is called,
290+ When `clone ` is called,
291291 Then the repository should be cloned and checked out at that branch.
292292 """
293293 repo_url = "https://github.com/cyclotruc/gitingest.git"
294294 branch_name = "main"
295295 local_path = tmp_path / "gitingest"
296296
297297 config = CloneConfig (url = repo_url , local_path = str (local_path ), branch = branch_name )
298- await clone_repo (config )
298+ await clone (config )
299299
300300 # Assertions
301301 assert local_path .exists (), "The repository was not cloned successfully."
@@ -312,7 +312,7 @@ async def test_clone_branch_with_slashes(tmp_path):
312312 Test cloning a branch with slashes in the name.
313313
314314 Given a valid repository URL and a branch name with slashes:
315- When `clone_repo ` is called,
315+ When `clone ` is called,
316316 Then the repository should be cloned and checked out at that branch.
317317 """
318318 repo_url = "https://github.com/user/repo"
@@ -322,7 +322,7 @@ async def test_clone_branch_with_slashes(tmp_path):
322322 clone_config = CloneConfig (url = repo_url , local_path = str (local_path ), branch = branch_name )
323323 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
324324 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
325- await clone_repo (clone_config )
325+ await clone (clone_config )
326326
327327 mock_exec .assert_called_once_with (
328328 "git" ,
@@ -337,12 +337,12 @@ async def test_clone_branch_with_slashes(tmp_path):
337337
338338
339339@pytest .mark .asyncio
340- async def test_clone_repo_creates_parent_directory (tmp_path : Path ) -> None :
340+ async def test_clone_creates_parent_directory (tmp_path : Path ) -> None :
341341 """
342- Test that clone_repo creates parent directories if they don't exist.
342+ Test that clone creates parent directories if they don't exist.
343343
344344 Given a local path with non-existent parent directories:
345- When `clone_repo ` is called,
345+ When `clone ` is called,
346346 Then it should create the parent directories before attempting to clone.
347347 """
348348 nested_path = tmp_path / "deep" / "nested" / "path" / "repo"
@@ -353,7 +353,7 @@ async def test_clone_repo_creates_parent_directory(tmp_path: Path) -> None:
353353
354354 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
355355 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
356- await clone_repo (clone_config )
356+ await clone (clone_config )
357357
358358 # Verify parent directory was created
359359 assert nested_path .parent .exists ()
@@ -375,14 +375,14 @@ async def test_clone_with_specific_subpath() -> None:
375375 Test cloning a repository with a specific subpath.
376376
377377 Given a valid repository URL and a specific subpath:
378- When `clone_repo ` is called,
378+ When `clone ` is called,
379379 Then the repository should be cloned with sparse checkout enabled and the specified subpath.
380380 """
381381 clone_config = CloneConfig (url = "https://github.com/user/repo" , local_path = "/tmp/repo" , subpath = "src/docs" )
382382
383383 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
384384 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
385- await clone_repo (clone_config )
385+ await clone (clone_config )
386386
387387 # Verify the clone command includes sparse checkout flags
388388 mock_exec .assert_any_call (
@@ -408,7 +408,7 @@ async def test_clone_with_commit_and_subpath() -> None:
408408 Test cloning a repository with both a specific commit and subpath.
409409
410410 Given a valid repository URL, commit hash, and subpath:
411- When `clone_repo ` is called,
411+ When `clone ` is called,
412412 Then the repository should be cloned with sparse checkout enabled,
413413 checked out at the specific commit, and only include the specified subpath.
414414 """
@@ -421,7 +421,7 @@ async def test_clone_with_commit_and_subpath() -> None:
421421
422422 with patch ("gitingest.cloning._check_repo_exists" , return_value = True ):
423423 with patch ("gitingest.cloning._run_command" , new_callable = AsyncMock ) as mock_exec :
424- await clone_repo (clone_config )
424+ await clone (clone_config )
425425
426426 # Verify the clone command includes sparse checkout flags
427427 mock_exec .assert_any_call (
0 commit comments