Skip to content

Commit 5d6d195

Browse files
Refactor module names to avoid function/module name clashes
- Renamed: - `clone.py` → `repository_clone.py` - `ingest.py` → `repository_ingest.py` - `ingest_from_query.py` → `query_ingestion.py` - `parse_query.py` → `query_parser.py` - Updated import statements accordingly in package `__init__.py`
1 parent 96bc395 commit 5d6d195

File tree

10 files changed

+31
-31
lines changed

10 files changed

+31
-31
lines changed

src/gitingest/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
""" Gitingest: A package for ingesting data from git repositories. """
22

3-
from gitingest.clone import clone_repo
4-
from gitingest.ingest import ingest
5-
from gitingest.ingest_from_query import ingest_from_query
6-
from gitingest.parse_query import parse_query
3+
from gitingest.query_ingestion import ingest_from_query
4+
from gitingest.query_parser import parse_query
5+
from gitingest.repository_clone import clone_repo
6+
from gitingest.repository_ingest import ingest
77

88
__all__ = ["ingest_from_query", "clone_repo", "parse_query", "ingest"]

src/gitingest/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import click
66

7-
from gitingest.ingest import ingest
8-
from gitingest.ingest_from_query import MAX_FILE_SIZE
7+
from gitingest.query_ingestion import MAX_FILE_SIZE
8+
from gitingest.repository_ingest import ingest
99

1010

1111
@click.command()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import shutil
66

77
from config import TMP_BASE_PATH
8-
from gitingest.clone import CloneConfig, clone_repo
9-
from gitingest.ingest_from_query import ingest_from_query
10-
from gitingest.parse_query import parse_query
8+
from gitingest.query_ingestion import ingest_from_query
9+
from gitingest.query_parser import parse_query
10+
from gitingest.repository_clone import CloneConfig, clone_repo
1111

1212

1313
def ingest(

src/process_query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from starlette.templating import _TemplateResponse
88

99
from config import EXAMPLE_REPOS, MAX_DISPLAY_SIZE
10-
from gitingest.clone import CloneConfig, clone_repo
11-
from gitingest.ingest_from_query import ingest_from_query
12-
from gitingest.parse_query import parse_query
10+
from gitingest.query_ingestion import ingest_from_query
11+
from gitingest.query_parser import parse_query
12+
from gitingest.repository_clone import CloneConfig, clone_repo
1313
from server_utils import Colors, log_slider_to_size
1414

1515
templates = Jinja2Templates(directory="templates")

tests/test_clone.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
""" Tests for the clone module. """
1+
""" Tests for the repository_clone module. """
22

33
from unittest.mock import AsyncMock, patch
44

55
import pytest
66

7-
from gitingest.clone import CloneConfig, _check_repo_exists, clone_repo
7+
from gitingest.repository_clone import CloneConfig, _check_repo_exists, clone_repo
88

99

1010
@pytest.mark.asyncio
@@ -20,8 +20,8 @@ async def test_clone_repo_with_commit() -> None:
2020
branch="main",
2121
)
2222

23-
with patch("gitingest.clone._check_repo_exists", return_value=True) as mock_check:
24-
with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec:
23+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True) as mock_check:
24+
with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec:
2525
mock_process = AsyncMock()
2626
mock_process.communicate.return_value = (b"output", b"error")
2727
mock_exec.return_value = mock_process
@@ -38,8 +38,8 @@ async def test_clone_repo_without_commit() -> None:
3838
"""
3939
query = CloneConfig(url="https://github.com/user/repo", local_path="/tmp/repo", commit=None, branch="main")
4040

41-
with patch("gitingest.clone._check_repo_exists", return_value=True) as mock_check:
42-
with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec:
41+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True) as mock_check:
42+
with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec:
4343
mock_process = AsyncMock()
4444
mock_process.communicate.return_value = (b"output", b"error")
4545
mock_exec.return_value = mock_process
@@ -61,7 +61,7 @@ async def test_clone_repo_nonexistent_repository() -> None:
6161
commit=None,
6262
branch="main",
6363
)
64-
with patch("gitingest.clone._check_repo_exists", return_value=False) as mock_check:
64+
with patch("gitingest.repository_clone._check_repo_exists", return_value=False) as mock_check:
6565
with pytest.raises(ValueError, match="Repository not found"):
6666
await clone_repo(clone_config)
6767
mock_check.assert_called_once_with(clone_config.url)
@@ -133,8 +133,8 @@ async def test_clone_repo_with_custom_branch() -> None:
133133
local_path="/tmp/repo",
134134
branch="feature-branch",
135135
)
136-
with patch("gitingest.clone._check_repo_exists", return_value=True):
137-
with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec:
136+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True):
137+
with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec:
138138
await clone_repo(clone_config)
139139
mock_exec.assert_called_once_with(
140140
"git",
@@ -158,8 +158,8 @@ async def test_git_command_failure() -> None:
158158
url="https://github.com/user/repo",
159159
local_path="/tmp/repo",
160160
)
161-
with patch("gitingest.clone._check_repo_exists", return_value=True):
162-
with patch("gitingest.clone._run_git_command", side_effect=RuntimeError("Git command failed")):
161+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True):
162+
with patch("gitingest.repository_clone._run_git_command", side_effect=RuntimeError("Git command failed")):
163163
with pytest.raises(RuntimeError, match="Git command failed"):
164164
await clone_repo(clone_config)
165165

@@ -174,8 +174,8 @@ async def test_clone_repo_default_shallow_clone() -> None:
174174
url="https://github.com/user/repo",
175175
local_path="/tmp/repo",
176176
)
177-
with patch("gitingest.clone._check_repo_exists", return_value=True):
178-
with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec:
177+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True):
178+
with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec:
179179
await clone_repo(clone_config)
180180
mock_exec.assert_called_once_with(
181181
"git", "clone", "--depth=1", "--single-branch", clone_config.url, clone_config.local_path
@@ -193,8 +193,8 @@ async def test_clone_repo_commit_without_branch() -> None:
193193
local_path="/tmp/repo",
194194
commit="a" * 40, # Simulating a valid commit hash
195195
)
196-
with patch("gitingest.clone._check_repo_exists", return_value=True):
197-
with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec:
196+
with patch("gitingest.repository_clone._check_repo_exists", return_value=True):
197+
with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec:
198198
await clone_repo(clone_config)
199199
assert mock_exec.call_count == 2 # Clone and checkout calls
200200
mock_exec.assert_any_call("git", "clone", "--single-branch", clone_config.url, clone_config.local_path)

tests/test_ingest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
""" Tests for the ingest_from_query module """
1+
""" Tests for the query_ingestion module """
22

33
from pathlib import Path
44
from typing import Any
55

6-
from gitingest.ingest_from_query import _extract_files_content, _scan_directory
6+
from gitingest.query_ingestion import _extract_files_content, _scan_directory
77

88

99
def test_scan_directory(temp_directory: Path, sample_query: dict[str, Any]) -> None:

tests/test_parse_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
""" Tests for the parse_query module. """
1+
""" Tests for the query_parser module. """
22

33
from pathlib import Path
44

55
import pytest
66

77
from gitingest.ignore_patterns import DEFAULT_IGNORE_PATTERNS
8-
from gitingest.parse_query import _parse_patterns, _parse_url, parse_query
8+
from gitingest.query_parser import _parse_patterns, _parse_url, parse_query
99

1010

1111
def test_parse_url_valid_https() -> None:

0 commit comments

Comments
 (0)