Skip to content

Commit

Permalink
Refactor: Replace os.path usage with pathlib.Path for improved mainta…
Browse files Browse the repository at this point in the history
…inability (#106)
  • Loading branch information
filipchristiansen authored Jan 7, 2025
1 parent 835fcbb commit 123f0ef
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 168 deletions.
4 changes: 3 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
""" Configuration file for the project. """

from pathlib import Path

MAX_DISPLAY_SIZE: int = 300_000
TMP_BASE_PATH: str = "/tmp/gitingest"
TMP_BASE_PATH = Path("/tmp/gitingest")
DELETE_REPO_AFTER: int = 60 * 60 # In seconds

EXAMPLE_REPOS: list[dict[str, str]] = [
Expand Down
8 changes: 4 additions & 4 deletions src/gitingest/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import inspect
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
Expand Down Expand Up @@ -63,7 +64,7 @@ def ingest(
# Extract relevant fields for CloneConfig
clone_config = CloneConfig(
url=query["url"],
local_path=query["local_path"],
local_path=str(query["local_path"]),
commit=query.get("commit"),
branch=query.get("branch"),
)
Expand All @@ -84,6 +85,5 @@ def ingest(
finally:
# Clean up the temporary directory if it was created
if query["url"]:
# Clean up the temporary directory under /tmp/gitingest
cleanup_path = "/tmp/gitingest"
shutil.rmtree(cleanup_path, ignore_errors=True)
# Clean up the temporary directory
shutil.rmtree(TMP_BASE_PATH, ignore_errors=True)
Loading

0 comments on commit 123f0ef

Please sign in to comment.