Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclotruc authored Jan 8, 2025
2 parents cb620cd + d2825ea commit d195003
Show file tree
Hide file tree
Showing 27 changed files with 739 additions and 334 deletions.
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ repos:
- id: isort
description: "Sort imports alphabetically, and automatically separated into sections and by type."

- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
hooks:
- id: pycln
description: "Remove unused import statements."

- repo: https://github.com/djlint/djLint
rev: v1.36.4
Expand Down
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# GitIngest
# Gitingest

[![Image](./docs/frontpage.png "GitIngest main page")](https://gitingest.com)
[![Image](./docs/frontpage.png "Gitingest main page")](https://gitingest.com)

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/cyclotruc/gitingest/blob/main/LICENSE)
[![PyPI version](https://badge.fury.io/py/gitingest.svg)](https://badge.fury.io/py/gitingest)
[![GitHub stars](https://img.shields.io/github/stars/cyclotruc/gitingest?style=social.svg)](https://github.com/cyclotruc/gitingest)
[![Downloads](https://pepy.tech/badge/gitingest)](https://pepy.tech/project/gitingest)
[![GitHub issues](https://img.shields.io/github/issues/cyclotruc/gitingest)](https://github.com/cyclotruc/gitingest/issues)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

[![Discord](https://dcbadge.limes.pink/api/server/https://discord.com/invite/zerRaGK9EC)](https://discord.com/invite/zerRaGK9EC)

Turn any Git repository into a prompt-friendly text ingest for LLMs.

You can also replace `hub` with `ingest` in any github url to access the coresponding digest
You can also replace `hub` with `ingest` in any GitHub URL to access the coresponding digest

[gitingest.com](https://gitingest.com)
[gitingest.com](https://gitingest.com/) · [Chrome Extension](https://chromewebstore.google.com/detail/adfjahbijlkjfoicpjkhjicpjpjfaood) · [Firefox Add-on](https://addons.mozilla.org/firefox/addon/gitingest/)

## 🚀 Features

Expand All @@ -25,7 +23,7 @@ You can also replace `hub` with `ingest` in any github url to access the corespo
- File and directory structure
- Size of the extract
- Token count
- **CLI tool**: Run it as a command (Currently on Linux only)
- **CLI tool**: Run it as a shell command (currently on Linux only)
- **Python package**: Import it in your code

## 📦 Installation
Expand All @@ -34,15 +32,26 @@ You can also replace `hub` with `ingest` in any github url to access the corespo
pip install gitingest
```

## 💡 Command Line usage
## 🧩 Browser Extension Usage

<!-- markdownlint-disable MD033 -->
<a href="https://chromewebstore.google.com/detail/adfjahbijlkjfoicpjkhjicpjpjfaood" target="_blank" title="Get Gitingest Extension from Chrome Web Store"><img height="48" src="https://github.com/user-attachments/assets/20a6e44b-fd46-4e6c-8ea6-aad436035753" alt="Available in the Chrome Web Store" /></a>
<a href="https://addons.mozilla.org/firefox/addon/gitingest/" target="_blank" title="Get Gitingest Extension from Firefox Add-ons"><img height="48" src="https://github.com/user-attachments/assets/c0e99e6b-97cf-4af2-9737-099db7d3538b" alt="Get The Add-on for Firefox" /></a>
<a href="https://microsoftedge.microsoft.com/addons/detail/nfobhllgcekbmpifkjlopfdfdmljmipf" target="_blank" title="Get Gitingest Extension from Firefox Add-ons"><img height="48" src="https://github.com/user-attachments/assets/204157eb-4cae-4c0e-b2cb-db514419fd9e" alt="Get from the Edge Add-ons" /></a>
<!-- markdownlint-enable MD033 -->

The extension is open source at [lcandy2/gitingest-extension](https://github.com/lcandy2/gitingest-extension).
Issues and feature requests are welcome to the repo.

## 💡 Command line usage

The `gitingest` command line tool allows you to analyze codebases and create a text dump of their contents.

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

# From url
# From URL
gitingest https://github.com/cyclotruc/gitingest

# See more options
Expand Down Expand Up @@ -95,15 +104,19 @@ If you are hosting it on a domain, you can specify the allowed hostnames via env
- [tiktoken](https://github.com/openai/tiktoken) - Token estimation
- [apianalytics.dev](https://www.apianalytics.dev/) - Simple Analytics

### Looking for a javascript/node package?

Check out the NPM alternative 📦 Repomix: <https://github.com/yamadashy/repomix>

## ✔️ Contributing to Gitingest

Gitingest aims to be friendly for first time contributors, with a simple python and html codebase.
If you need any help while working with the code, reach out to us on [discord](https://discord.com/invite/zerRaGK9EC)

### Ways to help (non-technical)

- Provide your feedback and ideas on discord
- Open an Issue on github to report a bug / submit an feature request
- Provide your feedback and ideas on Discord
- Open an issue on GitHub to report a bug / submit a feature request
- Talk about Gitingest on social media

### How to submit a PR
Expand All @@ -119,14 +132,14 @@ Gitingest aims to be friendly for first time contributors, with a simple python

### Run web UI locally

1. Clone the repository
1. Clone the repository:

```bash
git clone https://github.com/cyclotruc/gitingest.git
cd gitingest
```

2. Install dependencies
2. Install dependencies:

```bash
pip install -r requirements-dev.txt
Expand All @@ -142,7 +155,7 @@ Gitingest aims to be friendly for first time contributors, with a simple python
uvicorn main:app --reload
```

4. Run unit tests
4. Run unit tests:

```bash
pytest
Expand All @@ -152,13 +165,13 @@ The application should be available at `http://localhost:8000`

### Working on the CLI

1. Install the package in dev mode
1. Install the package in dev mode:

```bash
pip install -e .
```

2. Run the CLI
2. Run the CLI:

```bash
gitingest --help
Expand Down
6 changes: 4 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
""" 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]] = [
{"name": "GitIngest", "url": "https://github.com/cyclotruc/gitingest"},
{"name": "Gitingest", "url": "https://github.com/cyclotruc/gitingest"},
{"name": "FastAPI", "url": "https://github.com/tiangolo/fastapi"},
{"name": "Flask", "url": "https://github.com/pallets/flask"},
{"name": "Tldraw", "url": "https://github.com/tldraw/tldraw"},
Expand Down
6 changes: 3 additions & 3 deletions src/gitingest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
""" gitingest: A package for ingesting data from git repositories. """
""" Gitingest: A package for ingesting data from git repositories. """

from gitingest.clone import clone_repo
from gitingest.ingest import ingest
from gitingest.ingest_from_query import ingest_from_query
from gitingest.ingest_from_query import run_ingest_query
from gitingest.parse_query import parse_query

__all__ = ["ingest_from_query", "clone_repo", "parse_query", "ingest"]
__all__ = ["run_ingest_query", "clone_repo", "parse_query", "ingest"]
2 changes: 1 addition & 1 deletion src/gitingest/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Command-line interface for the GitIngest package. """
""" Command-line interface for the Gitingest package. """

# pylint: disable=no-value-for-parameter

Expand Down
2 changes: 1 addition & 1 deletion src/gitingest/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Custom exceptions for the GitIngest package. """
""" Custom exceptions for the Gitingest package. """


class InvalidPatternError(ValueError):
Expand Down
2 changes: 1 addition & 1 deletion src/gitingest/ignore_patterns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Default ignore patterns for GitIngest. """
""" Default ignore patterns for Gitingest. """

DEFAULT_IGNORE_PATTERNS: list[str] = [
# Python
Expand Down
12 changes: 6 additions & 6 deletions src/gitingest/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
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.ingest_from_query import run_ingest_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 @@ -74,7 +75,7 @@ def ingest(
else:
raise TypeError("clone_repo did not return a coroutine as expected.")

summary, tree, content = ingest_from_query(query)
summary, tree, content = run_ingest_query(query)

if output is not None:
with open(output, "w", encoding="utf-8") as f:
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 d195003

Please sign in to comment.