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
8 changes: 4 additions & 4 deletions .github/workflows/unitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .

- name: Run tests
run: |
pytest
pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ venv/
ENV/
env.bak/
venv.bak/
.python-version

# Spyder project settings
.spyderproject
Expand Down
78 changes: 78 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# Files
- id: check-added-large-files
description: 'Prevent large files from being committed.'
args: ['--maxkb=10000']
- id: check-case-conflict
description: 'Check for files that would conflict in case-insensitive filesystems.'
- id: fix-byte-order-marker
description: 'Remove utf-8 byte order marker.'
- id: mixed-line-ending
description: 'Replace mixed line ending.'

# Links
- id: destroyed-symlinks
description: 'Detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to.'

# File files for parseable syntax: python
- id: check-ast

# File and line endings
- id: end-of-file-fixer
description: 'Ensure that a file is either empty, or ends with one newline.'
- id: trailing-whitespace
description: 'Trim trailing whitespace.'

# Python
- id: check-docstring-first
description: 'Check a common error of defining a docstring after code.'
- id: requirements-txt-fixer
description: 'Sort entries in requirements.txt.'

- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
description: 'Automatically convert relative imports to absolute. (Use `args: [--never]` to revert.)'

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
description: 'Automatically upgrade syntax for newer versions.'
args: [--py3-plus, --py36-plus, --py38-plus]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
description: 'Enforce that `noqa` annotations always occur with specific codes. Sample annotations: `# noqa: F401`, `# noqa: F401,W203`.'
- id: python-check-blanket-type-ignore
description: 'Enforce that `# type: ignore` annotations always occur with specific codes. Sample annotations: `# type: ignore[attr-defined]`, `# type: ignore[attr-defined, name-defined]`.'
- id: python-use-type-annotations
description: 'Enforce that python3.6+ type annotations are used instead of type comments.'

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- 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
hooks:
- id: djlint-reformat-jinja
12 changes: 5 additions & 7 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
romain@coderamp.io.
<romain@coderamp.io>.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -114,15 +114,13 @@ the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at
<https://www.contributor-covenant.org/translations>.
80 changes: 53 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
[![Image](./docs/frontpage.png "GitIngest main page")](https://gitingest.com/)
[![Image](./docs/frontpage.png "GitIngest main page")](https://gitingest.com)

<!-- License -->
<a href="https://github.com/cyclotruc/gitingest/blob/main/LICENSE">
<img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg" />
</a>
<!-- PyPI version -->
<a href="https://badge.fury.io/py/gitingest">
<img src="https://badge.fury.io/py/gitingest.svg" alt="PyPI version" />
</a>
<!-- Downloads -->
<a href="https://pepy.tech/project/gitingest">
<img src="https://pepy.tech/badge/gitingest" alt="Downloads" />
</a>
<!-- GitHub issues -->
<a href="https://github.com/cyclotruc/gitingest/issues">
<img src="https://img.shields.io/github/issues/cyclotruc/gitingest" alt="GitHub issues" />
</a>
<!-- Black code style -->
<a href="https://github.com/psf/black">
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg" />
</a>

<!-- Discord -->
<a href="https://discord.com/invite/zerRaGK9EC">
<img src="https://dcbadge.limes.pink/api/server/https://discord.com/invite/zerRaGK9EC" alt="Discord" />
</a>

# GitIngest

![License](https://img.shields.io/badge/license-MIT-blue.svg)

# GitIngest 🔍
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

[gitingest.com](https://gitingest.com/)

[gitingest.com](https://gitingest.com)

## 🚀 Features

- **Easy code context**: Get a text digest from a git repository URL or a directory
- **Smart Formatting**: Optimized output format for LLM prompts
- **Statistics about**: :
- **Statistics about**:
- File and directory structure
- Size of the extract
- Token count
- Token count
- **CLI tool**: Run it as a command (Currently on Linux only)
- **Python package**: Import it in your code


## 📦 Installation

```
``` bash
pip install gitingest
```


## 💡 Command Line usage

The `gitingest` command line tool allows you to analyze codebases and create a text dump of their contents.
Expand All @@ -46,60 +68,62 @@ gitingest --help

This will write the digest in a text file (default `digest.txt`) in your current working directory.


## 🐛 Python package usage


```python
from gitingest import ingest

summary, tree, content = ingest("path/to/directory")

#or from URL
# or from URL
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest")
```

By default, this won't write a file but can be enabled with the `output` argument


## 🛠️ Using

- Tailwind CSS - Frontend
- [FastAPI](https://github.com/fastapi/fastapi) - Backend framework
- [tiktoken](https://github.com/openai/tiktoken) - Token estimation
- [apianalytics.dev](https://www.apianalytics.dev/) - Simple Analytics

## 🌐 Self-host

## 🌐 Self-host
1. Build the image:
```

``` bash
docker build -t gitingest .
```

2. Run the container:
```

``` bash
docker run -d --name gitingest -p 8000:8000 gitingest
```

The application will be available at `http://localhost:8000`
Ensure environment variables are set before running the application or deploying it via Docker.

## ✔️ Contributing

Contributions are welcome!
Contributions are welcome!

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 contribute
### Ways to contribute

1. Provide your feedback and ideas on discord
2. Open an Issue on github to report a bug
2. Create a Pull request
2. Open an Issue on github to report a bug
3. Create a Pull request
- Fork the repository
- Make your changes and test them locally
- Open a pull request for review and feedback

### 🔧 Local dev

#### Environment Configuration
#### Environment Configuration

- **`ALLOWED_HOSTS`**: Specify allowed hostnames for the application. Default: `"gitingest.com,*.gitingest.com,gitdigest.dev,localhost"`.
You can configure the application using the following environment variables:

Expand All @@ -108,23 +132,25 @@ ALLOWED_HOSTS="gitingest.local,localhost"
```

#### Run locally
1. Clone the repository

1. Clone the repository

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

2. Install dependencies

```bash
pip install -r requirements.txt
```

3. Run the application:

```bash
cd src
uvicorn main:app --reload
```

The frontend will be available at `localhost:8000`


The frontend will be available at `localhost:8000`
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

If you have discovered a vulnerability inside the project, report it privately at romain@coderamp.io. This way the maintainer can work on a proper fix without disclosing the problem to the public before it has been solved.
If you have discovered a vulnerability inside the project, report it privately at <romain@coderamp.io>. This way the maintainer can work on a proper fix without disclosing the problem to the public before it has been solved.
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tool.pylint.format]
max-line-length = 119

[tool.pycln]
all = true

[tool.isort]
profile = "black"
line_length = 119
remove_redundant_aliases = true
float_to_top = true
order_by_type = true
filter_files = true

[tool.black]
line-length = 119
skip-string-normalization = true
3 changes: 1 addition & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pythonpath = src
testpaths = src/gitingest/tests
asyncio_mode = auto


python_files = test_*.py
python_classes = Test*
python_functions = test_*
python_functions = test_*
15 changes: 10 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
fastapi[standard]
uvicorn
black
click>=8.0.0
djlint
fastapi-analytics
slowapi
tiktoken
fastapi[standard]
pre-commit
pytest
pytest-asyncio
click>=8.0.0
python-dotenv
slowapi
starlette
tiktoken
uvicorn
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

setup(
name="gitingest",
Expand Down Expand Up @@ -28,4 +28,4 @@
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
],
)
)
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAX_DISPLAY_SIZE = 300000
MAX_DISPLAY_SIZE = 300_000
TMP_BASE_PATH = "../tmp"

EXAMPLE_REPOS = [
Expand Down
10 changes: 5 additions & 5 deletions src/gitingest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .ingest_from_query import ingest_from_query
from .clone import clone_repo
from .parse_query import parse_query
from .ingest import ingest
from gitingest.clone import clone_repo
from gitingest.ingest import ingest
from gitingest.ingest_from_query import ingest_from_query
from gitingest.parse_query import parse_query

__all__ = ["ingest_from_query", "clone_repo", "parse_query", "ingest"]
__all__ = ["ingest_from_query", "clone_repo", "parse_query", "ingest"]
Loading
Loading