diff --git a/src/gitingest/__init__.py b/src/gitingest/__init__.py index d9fa918..afccf41 100644 --- a/src/gitingest/__init__.py +++ b/src/gitingest/__init__.py @@ -1,8 +1,8 @@ """ Gitingest: A package for ingesting data from git repositories. """ -from gitingest.clone import clone_repo -from gitingest.ingest import ingest -from gitingest.ingest_from_query import ingest_from_query -from gitingest.parse_query import parse_query +from gitingest.query_ingestion import ingest_from_query +from gitingest.query_parser import parse_query +from gitingest.repository_clone import clone_repo +from gitingest.repository_ingest import ingest __all__ = ["ingest_from_query", "clone_repo", "parse_query", "ingest"] diff --git a/src/gitingest/cli.py b/src/gitingest/cli.py index 6a4b470..ada231a 100644 --- a/src/gitingest/cli.py +++ b/src/gitingest/cli.py @@ -4,8 +4,8 @@ import click -from gitingest.ingest import ingest -from gitingest.ingest_from_query import MAX_FILE_SIZE +from gitingest.query_ingestion import MAX_FILE_SIZE +from gitingest.repository_ingest import ingest @click.command() diff --git a/src/gitingest/ingest_from_query.py b/src/gitingest/query_ingestion.py similarity index 100% rename from src/gitingest/ingest_from_query.py rename to src/gitingest/query_ingestion.py diff --git a/src/gitingest/parse_query.py b/src/gitingest/query_parser.py similarity index 100% rename from src/gitingest/parse_query.py rename to src/gitingest/query_parser.py diff --git a/src/gitingest/clone.py b/src/gitingest/repository_clone.py similarity index 100% rename from src/gitingest/clone.py rename to src/gitingest/repository_clone.py diff --git a/src/gitingest/ingest.py b/src/gitingest/repository_ingest.py similarity index 95% rename from src/gitingest/ingest.py rename to src/gitingest/repository_ingest.py index e58743d..11f58eb 100644 --- a/src/gitingest/ingest.py +++ b/src/gitingest/repository_ingest.py @@ -5,9 +5,9 @@ import shutil from config import TMP_BASE_PATH -from gitingest.clone import CloneConfig, clone_repo -from gitingest.ingest_from_query import ingest_from_query -from gitingest.parse_query import parse_query +from gitingest.query_ingestion import ingest_from_query +from gitingest.query_parser import parse_query +from gitingest.repository_clone import CloneConfig, clone_repo def ingest( diff --git a/src/process_query.py b/src/process_query.py index 7b28323..2e12909 100644 --- a/src/process_query.py +++ b/src/process_query.py @@ -7,9 +7,9 @@ from starlette.templating import _TemplateResponse from config import EXAMPLE_REPOS, MAX_DISPLAY_SIZE -from gitingest.clone import CloneConfig, clone_repo -from gitingest.ingest_from_query import ingest_from_query -from gitingest.parse_query import parse_query +from gitingest.query_ingestion import ingest_from_query +from gitingest.query_parser import parse_query +from gitingest.repository_clone import CloneConfig, clone_repo from server_utils import Colors, log_slider_to_size templates = Jinja2Templates(directory="templates") diff --git a/tests/test_clone.py b/tests/test_clone.py index 67f59a8..892bd04 100644 --- a/tests/test_clone.py +++ b/tests/test_clone.py @@ -1,10 +1,10 @@ -""" Tests for the clone module. """ +""" Tests for the repository_clone module. """ from unittest.mock import AsyncMock, patch import pytest -from gitingest.clone import CloneConfig, _check_repo_exists, clone_repo +from gitingest.repository_clone import CloneConfig, _check_repo_exists, clone_repo @pytest.mark.asyncio @@ -20,8 +20,8 @@ async def test_clone_repo_with_commit() -> None: branch="main", ) - with patch("gitingest.clone._check_repo_exists", return_value=True) as mock_check: - with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec: + with patch("gitingest.repository_clone._check_repo_exists", return_value=True) as mock_check: + with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec: mock_process = AsyncMock() mock_process.communicate.return_value = (b"output", b"error") mock_exec.return_value = mock_process @@ -38,8 +38,8 @@ async def test_clone_repo_without_commit() -> None: """ query = CloneConfig(url="https://github.com/user/repo", local_path="/tmp/repo", commit=None, branch="main") - with patch("gitingest.clone._check_repo_exists", return_value=True) as mock_check: - with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec: + with patch("gitingest.repository_clone._check_repo_exists", return_value=True) as mock_check: + with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec: mock_process = AsyncMock() mock_process.communicate.return_value = (b"output", b"error") mock_exec.return_value = mock_process @@ -61,7 +61,7 @@ async def test_clone_repo_nonexistent_repository() -> None: commit=None, branch="main", ) - with patch("gitingest.clone._check_repo_exists", return_value=False) as mock_check: + with patch("gitingest.repository_clone._check_repo_exists", return_value=False) as mock_check: with pytest.raises(ValueError, match="Repository not found"): await clone_repo(clone_config) mock_check.assert_called_once_with(clone_config.url) @@ -133,8 +133,8 @@ async def test_clone_repo_with_custom_branch() -> None: local_path="/tmp/repo", branch="feature-branch", ) - with patch("gitingest.clone._check_repo_exists", return_value=True): - with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec: + with patch("gitingest.repository_clone._check_repo_exists", return_value=True): + with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec: await clone_repo(clone_config) mock_exec.assert_called_once_with( "git", @@ -158,8 +158,8 @@ async def test_git_command_failure() -> None: url="https://github.com/user/repo", local_path="/tmp/repo", ) - with patch("gitingest.clone._check_repo_exists", return_value=True): - with patch("gitingest.clone._run_git_command", side_effect=RuntimeError("Git command failed")): + with patch("gitingest.repository_clone._check_repo_exists", return_value=True): + with patch("gitingest.repository_clone._run_git_command", side_effect=RuntimeError("Git command failed")): with pytest.raises(RuntimeError, match="Git command failed"): await clone_repo(clone_config) @@ -174,8 +174,8 @@ async def test_clone_repo_default_shallow_clone() -> None: url="https://github.com/user/repo", local_path="/tmp/repo", ) - with patch("gitingest.clone._check_repo_exists", return_value=True): - with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec: + with patch("gitingest.repository_clone._check_repo_exists", return_value=True): + with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec: await clone_repo(clone_config) mock_exec.assert_called_once_with( "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: local_path="/tmp/repo", commit="a" * 40, # Simulating a valid commit hash ) - with patch("gitingest.clone._check_repo_exists", return_value=True): - with patch("gitingest.clone._run_git_command", new_callable=AsyncMock) as mock_exec: + with patch("gitingest.repository_clone._check_repo_exists", return_value=True): + with patch("gitingest.repository_clone._run_git_command", new_callable=AsyncMock) as mock_exec: await clone_repo(clone_config) assert mock_exec.call_count == 2 # Clone and checkout calls mock_exec.assert_any_call("git", "clone", "--single-branch", clone_config.url, clone_config.local_path) diff --git a/tests/test_ingest.py b/tests/test_ingest.py index daf9057..886dafc 100644 --- a/tests/test_ingest.py +++ b/tests/test_ingest.py @@ -1,9 +1,9 @@ -""" Tests for the ingest_from_query module """ +""" Tests for the query_ingestion module """ from pathlib import Path from typing import Any -from gitingest.ingest_from_query import _extract_files_content, _scan_directory +from gitingest.query_ingestion import _extract_files_content, _scan_directory def test_scan_directory(temp_directory: Path, sample_query: dict[str, Any]) -> None: diff --git a/tests/test_parse_query.py b/tests/test_parse_query.py index fed1887..368d41f 100644 --- a/tests/test_parse_query.py +++ b/tests/test_parse_query.py @@ -1,11 +1,11 @@ -""" Tests for the parse_query module. """ +""" Tests for the query_parser module. """ from pathlib import Path import pytest from gitingest.ignore_patterns import DEFAULT_IGNORE_PATTERNS -from gitingest.parse_query import _parse_patterns, _parse_url, parse_query +from gitingest.query_parser import _parse_patterns, _parse_url, parse_query def test_parse_url_valid_https() -> None: