Skip to content

feat: enhance config options, support env vars #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Cheelax
Copy link

@Cheelax Cheelax commented Jul 5, 2025

Closes #285

  • add support for environment variables (GITINGEST_*) to override config.py defaults
  • implement a precedence hierarchy: CLI/Python args → environment variables → default values
  • introduce new CLI options (--max-files, --max-total-size, --max-directory-depth).
  • centralise environment variable utilities in utils/config_utils.py with functions _get_str_env_var and _get_int_env_var
  • add configuration examples to README.md
  • tidy and update docstrings
  • update tests
  • add missing --tag CLI flag
  • remove isort in favour of ruff.lint.isort
  • remove unused constants BASE_DIR and TEMPLATE_DIR in tests/server/test_flow_integration.py
  • rename constant templates to JINJA_TEMPLATES in src/server/server_config.py
  • move Colors from src/server/server_utils.py to src/gitingest/utils/colors.py to break circular import chain

@filipchristiansen
Copy link
Contributor

Thanks for your work @Cheelax. I have rebase upon main and added a commit with the following:

Refactor

  • Deduplicate _get_env_var by moving it to utils/config_utils.py.
  • Remove redundant local_path parameter from _process_file.

Fix

  • Add missing tag parameter to _async_main, main, and _CLIArgs.
  • Introduce the missing --tag CLI flag.

Docs and consistency

  • Update README.md for markdownlint compliance and other minor tweaks.
  • Add missing argument docs to _async_main docstring.
  • Re-order global variables in config.py for consistency.
  • Swap the order of include_patterns and ignore_patterns in parse_query and ingest_async.
  • Tidy docstrings for _async_main, IngestionQuery, parse_query, ingest_async, and ingest.

Tests

  • Temporarily disable [tool.ruff.lint.isort] due to conflict with the isort pre-commit hook.
  • Add new arguments to expected in test_parse_query_without_host.
  • Run pre-commit hooks.

TODO

  • The environment variable names such as GITINGEST_MAX_FILE_SIZE) do not seem to align with the names used and looked for in _get_env_var`.

  • The _get_env_var function returns int | str which causes downstream problems when the variables set with this functions are used (Type "int | str" is incompatible with type "int").

@Cheelax

This comment was marked as resolved.

@Cheelax
Copy link
Author

Cheelax commented Jul 23, 2025

@filipchristiansen Hello, any news on this?

@filipchristiansen
Copy link
Contributor

@filipchristiansen Hello, any news on this?

The code crashes when running the server locally, possibly due to a circular import. I will have a look at it.

@filipchristiansen
Copy link
Contributor

refactor(config,lint): centralize env utils, switch to ruff.isort, drop unused constants

  • remove isort in favour of ruff.lint.isort
  • remove unused constants BASE_DIR and TEMPLATE_DIR in tests/test_flow_integration.py
  • rename constant templates to JINJA_TEMPLATES in src/server/server_config.py
  • move function definition of _get_int_env_var from src/server/server_config.py to src/gitingest/utils/config_utils.py
  • remove duplicated function definition of _get_int_env_var in src/gitingest/config.py
  • rename function _get_env_var to _get_str_env_var for clarity
  • move Colors from src/server/server_utils.py to src/gitingest/utils/colors.py to break circular import chain

@filipchristiansen filipchristiansen changed the title Enhance configuration options feat: enhance configuration options Jul 23, 2025
@filipchristiansen
Copy link
Contributor

filipchristiansen commented Jul 23, 2025

@Cheelax The branch needs to be rebase upon main

Update: Done

Closes coderamp-labs#285

* add support for environment variables (`GITINGEST_*`) to override `config.py` defaults
* implement a precedence hierarchy: CLI/Python args → environment variables → default values
* introduce new CLI options (`--max-files`, `--max-total-size`, `--max-directory-depth`).
* centralise environment variable utilities in `utils/config_utils.py` with functions `_get_str_env_var` and `_get_int_env_var`
* add configuration examples to `README.md`
* tidy and update docstrings
* update tests

* add missing `--tag` CLI flag
* remove `isort` in favour of `ruff.lint.isort`
* remove unused constants `BASE_DIR` and `TEMPLATE_DIR` in `tests/server/test_flow_integration.py`
* rename constant `templates` to `JINJA_TEMPLATES` in `src/server/server_config.py`
* move `Colors` from `src/server/server_utils.py` to `src/gitingest/utils/colors.py` to break circular import chain

Co-authored-by: Cheelax <thomas.belloc@gmail.com>
@filipchristiansen filipchristiansen changed the title feat: enhance configuration options ### feat(config): enhance config options, support env vars Jul 24, 2025
@filipchristiansen filipchristiansen changed the title ### feat(config): enhance config options, support env vars feat(config): enhance config options, support env vars Jul 24, 2025
@filipchristiansen filipchristiansen changed the title feat(config): enhance config options, support env vars feat: enhance config options, support env vars Jul 24, 2025
Copy link
Contributor

@ix-56h ix-56h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ix-56h
Copy link
Contributor

ix-56h commented Jul 25, 2025

@filipchristiansen i'll let add your review and merge it.

Copy link

This pull request has merge conflicts that must be resolved before it can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: config parameters as environment variables
4 participants