Skip to content

Commit 1cad5b0

Browse files
committed
Package preparation work
1 parent c00416e commit 1cad5b0

23 files changed

+90
-89
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ testpaths = src/tests
44
asyncio_mode = auto
55

66
# Coverage configuration
7-
addopts = --cov=utils --cov=ingest --cov-report=term-missing --cov-report=html
7+
addopts = --no-cov
88

99
python_files = test_*.py
1010
python_classes = Test*

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ slowapi
55
tokencost
66
pytest
77
pytest-asyncio
8-
pytest-cov
98
click>=8.0.0

setup.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,39 @@
33
setup(
44
name="gitingest",
55
version="0.1.0",
6-
packages=find_packages(),
6+
packages=find_packages(where="src"),
7+
package_dir={"": "src"},
78
include_package_data=True,
89
install_requires=[
9-
"click",
10+
"click>=8.0.0",
11+
"tokencost",
1012
],
13+
extras_require={
14+
'dev': [
15+
'pytest',
16+
'pytest-asyncio',
17+
],
18+
},
1119
entry_points={
1220
"console_scripts": [
13-
"gitingest=src.cli:main",
21+
"gitingest=gitingest.cli:main",
1422
],
1523
},
1624
python_requires=">=3.6",
17-
author="Your Name",
25+
author="Romain Courtois",
26+
author_email="romain@coderamp.io",
1827
description="A tool to analyze and create text dumps of git repositories",
1928
long_description=open("README.md").read(),
2029
long_description_content_type="text/markdown",
21-
)
30+
url="https://github.com/cyclotruc/gitingest",
31+
classifiers=[
32+
"Development Status :: 3 - Alpha",
33+
"Intended Audience :: Developers",
34+
"License :: OSI Approved :: MIT License",
35+
"Programming Language :: Python :: 3",
36+
"Programming Language :: Python :: 3.6",
37+
"Programming Language :: Python :: 3.7",
38+
"Programming Language :: Python :: 3.8",
39+
"Programming Language :: Python :: 3.9",
40+
],
41+
)

src/config.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
MAX_DISPLAY_SIZE = 300000
2-
MAX_FILE_SIZE = 10000000
32
TMP_BASE_PATH = "../tmp"
4-
CLONE_TIMEOUT = 20
5-
6-
DEFAULT_IGNORE_PATTERNS = [
7-
'*.pyc', '*.pyo', '*.pyd', '__pycache__', # Python
8-
'node_modules', 'bower_components', # JavaScript
9-
'.git', '.svn', '.hg', '.gitignore', # Version control
10-
'*.svg', '*.png', '*.jpg', '*.jpeg', '*.gif', # Images
11-
'venv', '.venv', 'env', # Virtual environments
12-
'.idea', '.vscode', # IDEs
13-
'*.log', '*.bak', '*.swp', '*.tmp', # Temporary files
14-
'.DS_Store', # macOS
15-
'Thumbs.db', # Windows
16-
'build', 'dist', # Build directories
17-
'*.egg-info', # Python egg info
18-
'*.so', '*.dylib', '*.dll', # Compiled libraries
19-
'package-lock.json', 'yarn.lock', # Package lock files
20-
'pnpm-lock.yaml', 'npm-shrinkwrap.json', # More package lock files
21-
'COPYING.*', 'COPYRIGHT', # More license-related files
22-
'AUTHORS', 'AUTHORS.*', # Author files
23-
'CONTRIBUTORS', 'CONTRIBUTORS.*', # Contributor files
24-
'THANKS', 'THANKS.*', # Acknowledgment files
25-
'CHANGELOG', 'CHANGELOG.*', # Change logs
26-
'CONTRIBUTING', 'CONTRIBUTING.*' # Contribution guidelines
27-
]
283

294
EXAMPLE_REPOS = [
305
{"name": "Gitingest", "url": "https://github.com/cyclotruc/gitingest"},

src/gitingest/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .ingest import ingest_from_query
2+
from .clone import clone_repo
3+
from .parse_query import parse_query
4+
5+
6+
__all__ = ["ingest_from_query", "clone_repo", "parse_query"]

src/cli.py renamed to src/gitingest/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import click
21
import os
3-
from .ingest import analyze_codebase, DEFAULT_IGNORE_PATTERNS, MAX_FILE_SIZE
42
import pathlib
3+
import click
4+
5+
from .ingest import analyze_codebase, DEFAULT_IGNORE_PATTERNS, MAX_FILE_SIZE
56

67
def normalize_pattern(pattern: str) -> str:
78
pattern = pattern.strip()
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import asyncio
22
from typing import Tuple
33

4-
from .decorators import async_timeout
5-
from config import CLONE_TIMEOUT
4+
from gitingest.utils import async_timeout
65

7-
async def check_repo_exists(url: str) -> Tuple[bool, str]:
6+
CLONE_TIMEOUT = 20
7+
8+
async def check_repo_exists(url: str) -> bool:
89
proc = await asyncio.create_subprocess_exec(
910
"git",
1011
"ls-remote",
@@ -13,9 +14,7 @@ async def check_repo_exists(url: str) -> Tuple[bool, str]:
1314
stderr=asyncio.subprocess.PIPE,
1415
)
1516
await proc.communicate()
16-
if proc.returncode != 0:
17-
return False
18-
return True
17+
return proc.returncode == 0
1918

2019
@async_timeout(CLONE_TIMEOUT)
2120
async def clone_repo(query: dict) -> str:

src/ingest.py renamed to src/gitingest/ingest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22
from fnmatch import fnmatch
33
from typing import Dict, List, Union
4+
45
from tokencost import count_string_tokens
56

6-
# Configuration
7-
MAX_FILE_SIZE = 10000000 # 10MB
7+
MAX_FILE_SIZE = 10 * 1024 * 1024 # 10MB
88
MAX_DIRECTORY_DEPTH = 20 # Maximum depth of directory traversal
99
MAX_FILES = 10000 # Maximum number of files to process
10-
MAX_TOTAL_SIZE_BYTES = 500 * 1024 * 1024 # Total size limit
10+
MAX_TOTAL_SIZE_BYTES = 500 * 1024 * 1024 # 500MB
1111

1212
DEFAULT_IGNORE_PATTERNS = [
1313
# Python
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from typing import List
12
import uuid
23
import re
34
import os
4-
from utils.log_convert import logSliderToSize
5-
from typing import List
65

7-
from config import TMP_BASE_PATH, DEFAULT_IGNORE_PATTERNS
6+
from .ingest import DEFAULT_IGNORE_PATTERNS
7+
8+
TMP_BASE_PATH = "../tmp"
89

910
def parse_url(url: str) -> dict:
1011
parsed = {
@@ -71,9 +72,9 @@ def override_ignore_patterns(ignore_patterns: List[str], include_patterns: List[
7172
ignore_patterns.remove(pattern)
7273
return ignore_patterns
7374

74-
def parse_query(input_text: str, slider_position: int, pattern_type: str, pattern: str) -> dict:
75+
def parse_query(input_text: str, max_file_size: int, pattern_type: str, pattern: str) -> dict:
7576
query = parse_url(input_text)
76-
query['max_file_size'] = logSliderToSize(slider_position)
77+
query['max_file_size'] = max_file_size
7778
query['pattern_type'] = pattern_type
7879
parsed_pattern = parse_patterns(pattern)
7980
if pattern_type == 'include':

src/gitingest/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)