Skip to content

Commit 5ef116d

Browse files
Merge branch 'main' into VsCode-Extension
2 parents b275283 + 2592303 commit 5ef116d

File tree

5 files changed

+67
-14
lines changed

5 files changed

+67
-14
lines changed

src/gitingest/cli.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,40 @@ class _CLIArgs(TypedDict):
6161
"--output",
6262
"-o",
6363
default=None,
64-
help="Write to PATH (or '-' for stdout, default: <repo>.txt).",
64+
help="Output file path (default: digest.txt in current directory). Use '-' for stdout.",
6565
)
6666
def main(**cli_kwargs: Unpack[_CLIArgs]) -> None:
67-
"""Run the CLI entry point to analyze a repo / directory and dump its contents."""
67+
"""Run the CLI entry point to analyze a repo / directory and dump its contents.
68+
69+
Parameters
70+
----------
71+
**cli_kwargs : Unpack[_CLIArgs]
72+
A dictionary of keyword arguments forwarded to ``ingest_async``.
73+
74+
Notes
75+
-----
76+
See ``ingest_async`` for a detailed description of each argument.
77+
78+
Examples
79+
--------
80+
Basic usage:
81+
$ gitingest
82+
$ gitingest /path/to/repo
83+
$ gitingest https://github.com/user/repo
84+
85+
Output to stdout:
86+
$ gitingest -o -
87+
$ gitingest https://github.com/user/repo --output -
88+
89+
With filtering:
90+
$ gitingest -i "*.py" -e "*.log"
91+
$ gitingest --include-pattern "*.js" --exclude-pattern "node_modules/*"
92+
93+
Private repositories:
94+
$ gitingest https://github.com/user/private-repo -t ghp_token
95+
$ GITHUB_TOKEN=ghp_token gitingest https://github.com/user/private-repo
96+
97+
"""
6898
asyncio.run(_async_main(**cli_kwargs))
6999

70100

@@ -88,7 +118,7 @@ async def _async_main(
88118
Parameters
89119
----------
90120
source : str
91-
Directory path or Git repository URL.
121+
A directory path or a Git repository URL.
92122
max_size : int
93123
Maximum file size in bytes to ingest (default: 10 MB).
94124
exclude_pattern : tuple[str, ...] | None
@@ -103,7 +133,7 @@ async def _async_main(
103133
GitHub personal access token (PAT) for accessing private repositories.
104134
Can also be set via the ``GITHUB_TOKEN`` environment variable.
105135
output : str | None
106-
Destination file path. If ``None``, the output is written to ``<repo_name>.txt`` in the current directory.
136+
The path where the output file will be written (default: ``digest.txt`` in current directory).
107137
Use ``"-"`` to write to ``stdout``.
108138
109139
Raises

src/gitingest/entrypoint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pathlib import Path
1010

1111
from gitingest.clone import clone_repo
12-
from gitingest.config import MAX_FILE_SIZE, TMP_BASE_PATH
12+
from gitingest.config import MAX_FILE_SIZE
1313
from gitingest.ingestion import ingest_query
1414
from gitingest.query_parser import IngestionQuery, parse_query
1515
from gitingest.utils.auth import resolve_token
@@ -91,9 +91,9 @@ async def ingest_async(
9191

9292
return summary, tree, content
9393
finally:
94-
# Clean up the temporary directory if it was created
94+
# Clean up the temporary directory for the repository
9595
if repo_cloned:
96-
shutil.rmtree(TMP_BASE_PATH, ignore_errors=True)
96+
shutil.rmtree(query.local_path.parent)
9797

9898

9999
def ingest(

src/gitingest/utils/git_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ async def check_repo_exists(url: str, token: str | None = None) -> bool:
102102
If the curl command returns an unexpected status code.
103103
104104
"""
105-
expected_path_length = 2
106105
if token and is_github_host(url):
107106
return await _check_github_repo_exists(url, token=token)
108107

@@ -121,11 +120,13 @@ async def check_repo_exists(url: str, token: str | None = None) -> bool:
121120
response = stdout.decode()
122121
status_line = response.splitlines()[0].strip()
123122
parts = status_line.split(" ")
123+
124+
expected_path_length = 2
124125
if len(parts) >= expected_path_length:
125-
status_code_str = parts[1]
126-
if status_code_str in ("200", "301"):
126+
status = parts[1]
127+
if status in ("200", "301"):
127128
return True
128-
if status_code_str in ("302", "404"):
129+
if status in ("302", "404"):
129130
return False
130131
msg = f"Unexpected status line: {status_line}"
131132
raise RuntimeError(msg)

src/server/templates/components/git_form.jinja

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,29 @@
145145
name="token"
146146
placeholder="Personal Access Token"
147147
value="{{ token if token else '' }}"
148-
class="py-2 px-2 bg-[#E8F0FE] focus:outline-none w-full rounded">
148+
class="py-2 pl-2 pr-8 bg-[#E8F0FE] focus:outline-none w-full rounded">
149+
<!-- Info icon with tooltip -->
150+
<span class="absolute right-3 top-1/2 -translate-y-1/2">
151+
<!-- Icon -->
152+
<svg class="w-4 h-4 text-gray-600 cursor-pointer peer"
153+
xmlns="http://www.w3.org/2000/svg"
154+
fill="none"
155+
viewBox="0 0 24 24"
156+
stroke="currentColor"
157+
stroke-width="2">
158+
<circle cx="12" cy="12" r="10" />
159+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 16v-4m0-4h.01" />
160+
</svg>
161+
<!-- Tooltip (tooltip listens to peer-hover) -->
162+
<div class="absolute bottom-full mb-2 left-1/2 -translate-x-1/2 bg-gray-900 text-white text-xs leading-tight py-1 px-2 rounded shadow-lg opacity-0 pointer-events-none peer-hover:opacity-100 peer-hover:pointer-events-auto transition-opacity duration-200 whitespace-nowrap">
163+
<ul class="list-disc pl-4">
164+
<li>PAT is never stored in the backend</li>
165+
<li>Used once for cloning, then discarded from memory</li>
166+
<li>No browser caching</li>
167+
<li>Cloned repos are deleted after processing</li>
168+
</ul>
169+
</div>
170+
</span>
149171
</div>
150172
</div>
151173
<!-- Help section -->

src/static/llm.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,20 @@ gitingest https://github.com/user/private-repo -t $GITHUB_TOKEN -o -
176176
# Specific branch analysis (short flag)
177177
gitingest https://github.com/user/repo -b main -o -
178178

179-
# Save to file (default: <repo_name>.txt in current directory)
179+
# Save to file (default: digest.txt in current directory)
180180
gitingest https://github.com/user/repo -o my_analysis.txt
181181

182182
# Ultra-concise example for small files only
183183
gitingest https://github.com/user/repo -i "*.py" -s 51200 -o -
184184
```
185185

186186
**Key Parameters for AI Agents**:
187-
- `-o` / `--output`: Stream to STDOUT with `-` (default saves to `<repo_name>.txt`)
188187
- `-s` / `--max-size`: Maximum file size in bytes to process (default: no limit)
189188
- `-i` / `--include-pattern`: Include files matching Unix shell-style wildcards
190189
- `-e` / `--exclude-pattern`: Exclude files matching Unix shell-style wildcards
191190
- `-b` / `--branch`: Specify branch to analyze (defaults to repository's default branch)
192191
- `-t` / `--token`: GitHub personal access token for private repositories
192+
- `-o` / `--output`: Stream to STDOUT with `-` (default saves to `digest.txt`)
193193

194194
### 4.2 Python Package (Best for Code Integration)
195195
```python

0 commit comments

Comments
 (0)