Skip to content

Commit eb73a0c

Browse files
chore: add pre-commit config, type hints, badges, and lint codebase (#57)
* chore: add pre-commit config, type hints, badges, and lint codebase - Add .pre-commit-config.yaml and pyproject.toml for Black and isort - Add missing type hints throughout the code (Dict[...] for Python 3.8 compatibility) - Added badges and convert existing badges to use <a><img></a> format - Lint Markdown files - Lint Jinja templates with djlint * Resolve error and fix remaining type hint violations * Fix absolute imports and mock paths in test_clone.py to resolve test failures. * Replace deprecated 'dotenv' with 'python-dotenv' in requirements.txt to resolve installation errors.
1 parent 96fb7fe commit eb73a0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1048
-723
lines changed

.github/workflows/unitest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18-
18+
1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v4
2121
with:
2222
python-version: ${{ matrix.python-version }}
23-
23+
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip
2727
pip install pytest pytest-asyncio
2828
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
2929
pip install -e .
30-
30+
3131
- name: Run tests
3232
run: |
3333
pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ venv/
131131
ENV/
132132
env.bak/
133133
venv.bak/
134+
.python-version
134135

135136
# Spyder project settings
136137
.spyderproject

.pre-commit-config.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
# Files
6+
- id: check-added-large-files
7+
description: 'Prevent large files from being committed.'
8+
args: ['--maxkb=10000']
9+
- id: check-case-conflict
10+
description: 'Check for files that would conflict in case-insensitive filesystems.'
11+
- id: fix-byte-order-marker
12+
description: 'Remove utf-8 byte order marker.'
13+
- id: mixed-line-ending
14+
description: 'Replace mixed line ending.'
15+
16+
# Links
17+
- id: destroyed-symlinks
18+
description: 'Detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to.'
19+
20+
# File files for parseable syntax: python
21+
- id: check-ast
22+
23+
# File and line endings
24+
- id: end-of-file-fixer
25+
description: 'Ensure that a file is either empty, or ends with one newline.'
26+
- id: trailing-whitespace
27+
description: 'Trim trailing whitespace.'
28+
29+
# Python
30+
- id: check-docstring-first
31+
description: 'Check a common error of defining a docstring after code.'
32+
- id: requirements-txt-fixer
33+
description: 'Sort entries in requirements.txt.'
34+
35+
- repo: https://github.com/MarcoGorelli/absolufy-imports
36+
rev: v0.3.1
37+
hooks:
38+
- id: absolufy-imports
39+
description: 'Automatically convert relative imports to absolute. (Use `args: [--never]` to revert.)'
40+
41+
- repo: https://github.com/psf/black
42+
rev: 24.10.0
43+
hooks:
44+
- id: black
45+
46+
- repo: https://github.com/asottile/pyupgrade
47+
rev: v3.19.1
48+
hooks:
49+
- id: pyupgrade
50+
description: 'Automatically upgrade syntax for newer versions.'
51+
args: [--py3-plus, --py36-plus, --py38-plus]
52+
53+
- repo: https://github.com/pre-commit/pygrep-hooks
54+
rev: v1.10.0
55+
hooks:
56+
- id: python-check-blanket-noqa
57+
description: 'Enforce that `noqa` annotations always occur with specific codes. Sample annotations: `# noqa: F401`, `# noqa: F401,W203`.'
58+
- id: python-check-blanket-type-ignore
59+
description: 'Enforce that `# type: ignore` annotations always occur with specific codes. Sample annotations: `# type: ignore[attr-defined]`, `# type: ignore[attr-defined, name-defined]`.'
60+
- id: python-use-type-annotations
61+
description: 'Enforce that python3.6+ type annotations are used instead of type comments.'
62+
63+
- repo: https://github.com/PyCQA/isort
64+
rev: 5.13.2
65+
hooks:
66+
- id: isort
67+
description: 'Sort imports alphabetically, and automatically separated into sections and by type.'
68+
69+
- repo: https://github.com/hadialqattan/pycln
70+
rev: v2.4.0
71+
hooks:
72+
- id: pycln
73+
description: 'Remove unused import statements.'
74+
75+
- repo: https://github.com/djlint/djLint
76+
rev: v1.36.4
77+
hooks:
78+
- id: djlint-reformat-jinja

CODE_OF_CONDUCT.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ representative at an online or offline event.
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6262
reported to the community leaders responsible for enforcement at
63-
63+
6464
All complaints will be reviewed and investigated promptly and fairly.
6565

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

115115
## Attribution
116116

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

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

124-
[homepage]: https://www.contributor-covenant.org
125-
126124
For answers to common questions about this code of conduct, see the FAQ at
127-
https://www.contributor-covenant.org/faq. Translations are available at
128-
https://www.contributor-covenant.org/translations.
125+
<https://www.contributor-covenant.org/faq>. Translations are available at
126+
<https://www.contributor-covenant.org/translations>.

README.md

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
1-
[![Image](./docs/frontpage.png "GitIngest main page")](https://gitingest.com/)
1+
[![Image](./docs/frontpage.png "GitIngest main page")](https://gitingest.com)
2+
3+
<!-- License -->
4+
<a href="https://github.com/cyclotruc/gitingest/blob/main/LICENSE">
5+
<img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg" />
6+
</a>
7+
<!-- PyPI version -->
8+
<a href="https://badge.fury.io/py/gitingest">
9+
<img src="https://badge.fury.io/py/gitingest.svg" alt="PyPI version" />
10+
</a>
11+
<!-- Downloads -->
12+
<a href="https://pepy.tech/project/gitingest">
13+
<img src="https://pepy.tech/badge/gitingest" alt="Downloads" />
14+
</a>
15+
<!-- GitHub issues -->
16+
<a href="https://github.com/cyclotruc/gitingest/issues">
17+
<img src="https://img.shields.io/github/issues/cyclotruc/gitingest" alt="GitHub issues" />
18+
</a>
19+
<!-- Black code style -->
20+
<a href="https://github.com/psf/black">
21+
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg" />
22+
</a>
23+
24+
<!-- Discord -->
25+
<a href="https://discord.com/invite/zerRaGK9EC">
26+
<img src="https://dcbadge.limes.pink/api/server/https://discord.com/invite/zerRaGK9EC" alt="Discord" />
27+
</a>
28+
29+
# GitIngest
230

3-
![License](https://img.shields.io/badge/license-MIT-blue.svg)
4-
5-
# GitIngest 🔍
631
Turn any Git repository into a prompt-friendly text ingest for LLMs.
732

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

10-
[gitingest.com](https://gitingest.com/)
11-
35+
[gitingest.com](https://gitingest.com)
1236

1337
## 🚀 Features
1438

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

24-
2548
## 📦 Installation
2649

27-
```
50+
``` bash
2851
pip install gitingest
2952
```
3053

31-
3254
## 💡 Command Line usage
3355

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

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

49-
5071
## 🐛 Python package usage
5172

52-
5373
```python
5474
from gitingest import ingest
5575

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

58-
#or from URL
78+
# or from URL
5979
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest")
6080
```
6181

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

64-
6584
## 🛠️ Using
85+
6686
- Tailwind CSS - Frontend
6787
- [FastAPI](https://github.com/fastapi/fastapi) - Backend framework
6888
- [tiktoken](https://github.com/openai/tiktoken) - Token estimation
6989
- [apianalytics.dev](https://www.apianalytics.dev/) - Simple Analytics
7090

91+
## 🌐 Self-host
7192

72-
## 🌐 Self-host
7393
1. Build the image:
74-
```
94+
95+
``` bash
7596
docker build -t gitingest .
7697
```
7798

7899
2. Run the container:
79-
```
100+
101+
``` bash
80102
docker run -d --name gitingest -p 8000:8000 gitingest
81103
```
104+
82105
The application will be available at `http://localhost:8000`
83106
Ensure environment variables are set before running the application or deploying it via Docker.
84107

85108
## ✔️ Contributing
86109

87-
Contributions are welcome!
110+
Contributions are welcome!
88111

89112
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)
90113

91-
### Ways to contribute
114+
### Ways to contribute
92115

93116
1. Provide your feedback and ideas on discord
94-
2. Open an Issue on github to report a bug
95-
2. Create a Pull request
117+
2. Open an Issue on github to report a bug
118+
3. Create a Pull request
96119
- Fork the repository
97120
- Make your changes and test them locally
98121
- Open a pull request for review and feedback
99122

100123
### 🔧 Local dev
101124

102-
#### Environment Configuration
125+
#### Environment Configuration
126+
103127
- **`ALLOWED_HOSTS`**: Specify allowed hostnames for the application. Default: `"gitingest.com,*.gitingest.com,gitdigest.dev,localhost"`.
104128
You can configure the application using the following environment variables:
105129

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

110134
#### Run locally
111-
1. Clone the repository
135+
136+
1. Clone the repository
137+
112138
```bash
113139
git clone https://github.com/cyclotruc/gitingest.git
114140
cd gitingest
115141
```
116142

117143
2. Install dependencies
144+
118145
```bash
119146
pip install -r requirements.txt
120147
```
121148

122149
3. Run the application:
150+
123151
```bash
124152
cd src
125153
uvicorn main:app --reload
126154
```
127155

128-
The frontend will be available at `localhost:8000`
129-
130-
156+
The frontend will be available at `localhost:8000`

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Reporting a Vulnerability
44

5-
If you have discovered a vulnerability inside the project, report it privately at [email protected]. This way the maintainer can work on a proper fix without disclosing the problem to the public before it has been solved.
5+
If you have discovered a vulnerability inside the project, report it privately at <[email protected]>. This way the maintainer can work on a proper fix without disclosing the problem to the public before it has been solved.

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tool.pylint.format]
2+
max-line-length = 119
3+
4+
[tool.pycln]
5+
all = true
6+
7+
[tool.isort]
8+
profile = "black"
9+
line_length = 119
10+
remove_redundant_aliases = true
11+
float_to_top = true
12+
order_by_type = true
13+
filter_files = true
14+
15+
[tool.black]
16+
line-length = 119
17+
skip-string-normalization = true

pytest.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pythonpath = src
33
testpaths = src/gitingest/tests
44
asyncio_mode = auto
55

6-
76
python_files = test_*.py
87
python_classes = Test*
9-
python_functions = test_*
8+
python_functions = test_*

requirements.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
fastapi[standard]
2-
uvicorn
1+
black
2+
click>=8.0.0
3+
djlint
34
fastapi-analytics
4-
slowapi
5-
tiktoken
5+
fastapi[standard]
6+
pre-commit
67
pytest
78
pytest-asyncio
8-
click>=8.0.0
9+
python-dotenv
10+
slowapi
11+
starlette
12+
tiktoken
13+
uvicorn

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import find_packages, setup
22

33
setup(
44
name="gitingest",
@@ -28,4 +28,4 @@
2828
"License :: OSI Approved :: MIT License",
2929
"Programming Language :: Python :: 3",
3030
],
31-
)
31+
)

0 commit comments

Comments
 (0)