Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
MAX_TOTAL_SIZE_BYTES = 500 * 1024 * 1024 # 500 MB

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

OUTPUT_FILE_PATH = "digest.txt"
TMP_BASE_PATH = Path("/tmp/gitingest")

EXAMPLE_REPOS: list[dict[str, str]] = [
{"name": "Gitingest", "url": "https://github.com/cyclotruc/gitingest"},
{"name": "FastAPI", "url": "https://github.com/tiangolo/fastapi"},
Expand Down
4 changes: 2 additions & 2 deletions src/gitingest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import click

from config import MAX_FILE_SIZE
from config import MAX_FILE_SIZE, OUTPUT_FILE_PATH
from gitingest.repository_ingest import ingest


Expand Down Expand Up @@ -84,7 +84,7 @@ async def _async_main(
include_patterns = set(include_pattern)

if not output:
output = "digest.txt"
output = OUTPUT_FILE_PATH
summary, _, _ = await ingest(source, max_size, include_patterns, exclude_patterns, output=output)

click.echo(f"Analysis complete! Output written to: {output}")
Expand Down
41 changes: 41 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
""" Tests for the gitingest cli """

import os

from click.testing import CliRunner

from config import MAX_FILE_SIZE, OUTPUT_FILE_PATH
from gitingest.cli import main


def test_cli_with_default_options():
runner = CliRunner()
result = runner.invoke(main, ["../"])
output_lines = result.output.strip().split("\n")
assert f"Analysis complete! Output written to: {OUTPUT_FILE_PATH}" in output_lines
assert os.path.exists(OUTPUT_FILE_PATH), f"Output file was not created at {OUTPUT_FILE_PATH}"

os.remove(OUTPUT_FILE_PATH)


def test_cli_with_options():
runner = CliRunner()
result = runner.invoke(
main,
[
"../",
"--output",
OUTPUT_FILE_PATH,
"--max-size",
MAX_FILE_SIZE,
"--exclude-pattern",
"tests/",
"--include-pattern",
"src/",
],
)
output_lines = result.output.strip().split("\n")
assert f"Analysis complete! Output written to: {OUTPUT_FILE_PATH}" in output_lines
assert os.path.exists(OUTPUT_FILE_PATH), f"Output file was not created at {OUTPUT_FILE_PATH}"

os.remove(OUTPUT_FILE_PATH)
Loading