Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for local repositories #49

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,27 @@ uvicorn main:app --reload

The frontend will be available at `localhost:8000`

## 🗂️ Using Local Directories
vishwamartur marked this conversation as resolved.
Show resolved Hide resolved

In addition to GitHub Public repo URLs, you can now use local directories with the CLI and Python package.

### CLI usage with local directories

```bash
# Basic usage with local directory
gitingest /path/to/local/directory

# See more options
gitingest --help
```

### Python package usage with local directories

```python
from gitingest import ingest

# Ingest from a local directory
summary, tree, content = ingest("/path/to/local/directory")
```

By default, this won't write a file but can be enabled with the `output` argument.
5 changes: 4 additions & 1 deletion src/gitingest/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ def ingest(source: str, max_file_size: int = 10 * 1024 * 1024, include_patterns:
if query['url']:
# Get parent directory two levels up from local_path (../tmp)
cleanup_path = str(Path(query['local_path']).parents[1])
shutil.rmtree(cleanup_path, ignore_errors=True)
shutil.rmtree(cleanup_path, ignore_errors=True)
elif Path(source).is_dir():
# If the source is a local directory, no need to clean up
pass
1 change: 0 additions & 1 deletion src/gitingest/ingest_from_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,3 @@ def ingest_from_query(query: dict) -> Dict:
return ingest_single_file(path, query)
else:
return ingest_directory(path, query)

48 changes: 47 additions & 1 deletion src/templates/components/github_form.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,52 @@
</div>
</div>

<div class="mt-4 relative z-20 flex flex-wrap gap-4 items-start">
<!-- File input for local directories -->
<div class="w-[200px] sm:w-[250px] mr-9 mt-4">
<div class="relative">
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0 z-10"></div>
<div class="flex relative z-20 border-[3px] border-gray-900 rounded bg-white">
<input type="file"
id="local_directory"
name="local_directory"
webkitdirectory
directory
class="py-2 px-2 bg-[#E8F0FE] focus:outline-none w-full">
</div>
</div>
</div>
</div>

<div class="mt-4 relative z-20 flex flex-wrap gap-4 items-start">
<!-- Checkbox to select between local directory and remote repo -->
<div class="w-[200px] sm:w-[250px] mr-9 mt-4">
<div class="relative">
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0 z-10"></div>
<div class="flex relative z-20 border-[3px] border-gray-900 rounded bg-white">
<input type="checkbox"
id="local_directory_checkbox"
name="local_directory_checkbox"
class="py-2 px-2 bg-[#E8F0FE] focus:outline-none w-full">
<label for="local_directory_checkbox" class="py-2 px-2 bg-[#E8F0FE] focus:outline-none w-full">Local Directory</label>
</div>
</div>
</div>

<div class="w-[200px] sm:w-[250px] mr-9 mt-4">
<div class="relative">
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0 z-10"></div>
<div class="flex relative z-20 border-[3px] border-gray-900 rounded bg-white">
<input type="checkbox"
id="remote_repo_checkbox"
name="remote_repo_checkbox"
class="py-2 px-2 bg-[#E8F0FE] focus:outline-none w-full">
<label for="remote_repo_checkbox" class="py-2 px-2 bg-[#E8F0FE] focus:outline-none w-full">Remote Repo</label>
</div>
</div>
</div>
</div>

{% if show_examples %}
<!-- Example repositories section -->
<div class="mt-4">
Expand All @@ -101,4 +147,4 @@
</div>
{% endif %}
</div>
</div>
</div>
29 changes: 15 additions & 14 deletions src/templates/components/result.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 012-2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
</svg>
Copy
</button>
Expand Down Expand Up @@ -93,23 +93,24 @@
class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
</svg>
Copy
</button>
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 012-2h2a2 2 0 012-2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
</svg>
Copy
</button>
</div>
</div>
</div>
<div class="relative">
<div
class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
<div class="relative">
<div
class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
</div>
<textarea
class="result-text w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10"
style="min-height: {{ '600px' if content else 'calc(100vh-800px)' }}"
readonly>{{ content }}</textarea>
</div>
<textarea
class="result-text w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10"
style="min-height: {{ '600px' if content else 'calc(100vh-800px)' }}"
readonly>{{ content }}</textarea>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endif %}