Skip to content

Commit 123f0ef

Browse files
Refactor: Replace os.path usage with pathlib.Path for improved maintainability (#106)
1 parent 835fcbb commit 123f0ef

File tree

10 files changed

+174
-168
lines changed

10 files changed

+174
-168
lines changed

src/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
""" Configuration file for the project. """
22

3+
from pathlib import Path
4+
35
MAX_DISPLAY_SIZE: int = 300_000
4-
TMP_BASE_PATH: str = "/tmp/gitingest"
6+
TMP_BASE_PATH = Path("/tmp/gitingest")
57
DELETE_REPO_AFTER: int = 60 * 60 # In seconds
68

79
EXAMPLE_REPOS: list[dict[str, str]] = [

src/gitingest/ingest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import inspect
55
import shutil
66

7+
from config import TMP_BASE_PATH
78
from gitingest.clone import CloneConfig, clone_repo
89
from gitingest.ingest_from_query import ingest_from_query
910
from gitingest.parse_query import parse_query
@@ -63,7 +64,7 @@ def ingest(
6364
# Extract relevant fields for CloneConfig
6465
clone_config = CloneConfig(
6566
url=query["url"],
66-
local_path=query["local_path"],
67+
local_path=str(query["local_path"]),
6768
commit=query.get("commit"),
6869
branch=query.get("branch"),
6970
)
@@ -84,6 +85,5 @@ def ingest(
8485
finally:
8586
# Clean up the temporary directory if it was created
8687
if query["url"]:
87-
# Clean up the temporary directory under /tmp/gitingest
88-
cleanup_path = "/tmp/gitingest"
89-
shutil.rmtree(cleanup_path, ignore_errors=True)
88+
# Clean up the temporary directory
89+
shutil.rmtree(TMP_BASE_PATH, ignore_errors=True)

0 commit comments

Comments
 (0)