* refactor: centralize PAT validation, streamline repo checks & housekeeping
* `.venv*` to `.gitignore`
* `# type: ignore[attr-defined]` hints in `compat_typing.py` for IDE-agnostic imports
* Helpful PAT string in `InvalidGitHubTokenError` for easier debugging
* Bump **ruff-pre-commit** hook → `v0.12.1`
* CONTRIBUTING:
* Require **Python 3.9+**
* Recommend signed (`-S`) commits
* PAT validation now happens **only** in entry points
(`utils.auth.resolve_token` for CLI/lib, `server.process_query` for Web UI)
* Unified `_check_github_repo_exists` into `check_repo_exists`, replacing
`curl -I` with `curl --silent --location --write-out %{http_code} -o /dev/null`
* Broaden `_GITHUB_PAT_PATTERN`
* `create_git_auth_header` raises `ValueError` when hostname is missing
* Tests updated to expect raw HTTP-code output
* Superfluous “token can be set via `GITHUB_TOKEN`” notes in docstrings
* `.gitingestignore` & `.terraform` from `DEFAULT_IGNORE_PATTERNS`
* Token validation inside `create_git_command`
* Obsolete `test_create_git_command_invalid_token`
* Adjust `test_clone.py` and `test_git_utils.py` for new status-code handling
* Consolidate mocks after token-validation relocation
BREAKING CHANGE:
`create_git_command` no longer validates GitHub tokens; callers must ensure
tokens are valid (via `validate_github_token`) before invoking lower-level
git helpers.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add option to output digest to stdout
This change introduces the ability for users to direct the output of the gitingest tool to standard output (stdout) instead of writing to a file. This is useful for piping the output to other commands or viewing it directly in the terminal.
Co-authored-by: Filip Christiansen <22807962+filipchristiansen@users.noreply.github.com>
- Remove chardet and fastapi-analytics references from .pre-commit-config.yaml and requirements
- Pin fastapi, starlette, and uvicorn to versions fixing known vulnerabilities
- Add pydantic to requirements
- Update ingestion_schema to use pydantic's new ConfigDict
* Add Python 3.9 support by using ParamSpec from typing_extensions and removing match statements
* Add Python 3.7 support by reverting inline generics and removing walrus usage
* Update pyproject.toml
* Refactor project structure, enhance logic, update configurations, and improve code quality
Refactoring and Logic Improvements
- Refactored the `_scan_directory` function in `src/gitingest/ingest_from_query.py` by extracting loop logic into the new `_process_item` function, and further separating functionality into `_process_symlink` and `_process_file`
- Replaced multiple return statements with error raising and catching, introducing custom exceptions (`MaxFilesReachedError`, `MaxFileSizeReachedError`, `AlreadyVisitedError`) in the `_process_item` and `_scan_directory` functions
- Enhanced the logic in the `process_query` function in `src/process_query.py` for better flow and maintainability
- Improved the logic in `_generate_token_string` in `src/gitingest/ingest_from_query.py`
- Refined the `download_ingest` function in `src/routers/download.py` for better clarity and functionality
Exception Handling Enhancements
- Replaced broad `Exception` handling with specific `OSError` in the `_read_file_content` function in `src/gitingest/ingest_from_query.py`
- Refined exception handling throughout the codebase, including removing redundant try-except-raise blocks, e.g., in `clone_repo` function in `src/gitingest/clone.py`
- Added custom exceptions to `src/gitingest/exceptions.py`: `MaxFilesReachedError`, `MaxFileSizeReachedError`, and `AlreadyVisitedError`
- Included explicit re-raising of exceptions in various functions for improved error propagation
Test Suite Refactoring
- Cleaned up and reorganized test files:
- Moved tests from `src/gitingest/tests/` to `tests/`
- Consolidated fixtures from `tests/test_ingest.py` into `tests/conftest.py`
- Removed redundant content from `tests/conftest.py`
- Migrated configuration from `pytest.ini` to `pyproject.toml`, deleted `pytest.ini`, and updated `.dockerignore`
Documentation Improvements
- Added `darglint` for enforcing `numpy` docstring style in `.pre-commit-config.yaml` for `src/` files
- Updated docstrings throughout the codebase, including adding module docstrings where needed
- Updated `README.md`:
- Added "GitHub stars" badge
- Moved the "Discord" badge to its own line
- Replaced occurrences of "Gitingest" with "GitIngest" for consistency and clarity
Linting and Code Quality
- Integrated `pylint` into `.pre-commit-config.yaml` for both `src/` and `tests/` directories
- Created `tests/.pylintrc` for linting configuration specific to test files
Code Clean-up
- Removed the redundant `src/__init__.py` file
Naming Conventions and Code Style
- Renamed `logSliderToSize` to `log_slider_to_size` in `src/server_utils.py` for consistency with Python's naming conventions
- Added explicit encoding specification in multiple instances of `open` throughout the code
Code Quality:
- Add markdownlint to pre-commit hooks for consistent markdown formatting
- Add missing type hints to constants and variables
- Prefix helper functions with underscore for better encapsulation
Documentation:
- Update README.md to follow markdown best practices
- Add docstrings to functions in process_query.py, server_utils.py and main.py
Refactoring:
- Remove redundant normalize_pattern function from client.py
- Simplify logic in should_exclude function in ingest_from_query.py
- Improve code organization in clone.py
- Move async_timeout comment into function body for better context
Updated Type Hints:
Used pyupgrade with --py39-plus and --py310-plus flags to upgrade type hints to Python 3.9+ and 3.10+ syntax.
Enforced Double Quotes:
Removed skip-string-normalization = true from the black configuration in pyproject.toml.
Reran black via pre-commit hooks to enforce double quotes in the codebase.
Refactored Dependency Management:
Split requirements.txt into requirements.txt (runtime dependencies) and requirements-dev.txt (development dependencies).
Enhanced CI Workflow:
Integrated pre-commit hooks into the CI pipeline to enforce code quality checks automatically.
Added pip caching to the CI workflow to speed up dependency installation.
Automated Package Publishing:
Added a publish.yml GitHub Actions workflow to automate publishing to PyPI.
The workflow triggers on release creation or manual dispatch, builds the package, and publishes it to PyPI using twine.
* 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.