Skip to content

Conversation

@filipchristiansen
Copy link
Contributor

Why

Until now the gitingest.com web UI could ingest only public repositories.
Teams often need to analyse private GitHub repos, so we’re adding a way to supply a personal access token (PAT).

What’s inside

Area Key changes
UI • New “🔒 Private Repository” checkbox in git_form.jinja that reveals a masked PAT field.
• Checkbox state + token are posted with the form.
Server routes index.py, dynamic.py, query_processor.py accept token from the form and thread it downstream.
Ingestion stack gitingest.entrypoint.parse_query and query_parsing now carry token, letting try_domains_for_user_and_repo() resolve bare user/repo slugs against GitHub also when a PAT is present.
Tests • Added "token": "" to form_data in tests/test_flow_integration.py to keep path-coverage intact.

Limitation: This PR enables PAT-protected cloning only for GitHub; other hosts (GitLab, Gitea, etc.) remain public-only for now.

…authentication

* Accept a GitHub personal access token (PAT) from the UI and forward it through
  - `git_form.jinja` → new “Private Repository” checkbox + PAT field
  - routers (`index.py`, `dynamic.py`) and `query_processor.py`
* Propagate `token` throughout the ingestion stack
  - `gitingest.entrypoint.parse_query`
  - `query_parsing` (including `try_domains_for_user_and_repo`) so we can infer the host when the user enters a bare “user/repo” slug
* Tests
  - Added `"token": ""` to the `form_data` dict in the tests in `tests/test_flow_integration.py`

**Limitation:** This PR enables PAT-protected cloning **only for GitHub**; other hosts (GitLab, Gitea, etc.) remain public-only for now.
@filipchristiansen filipchristiansen requested review from Copilot and cyclotruc and removed request for Copilot June 20, 2025 12:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for supplying a GitHub personal access token (PAT) so private repos can be ingested through the web UI and backend.

  • UI: New “Private Repository” checkbox and masked PAT field in the ingest form
  • Backend: Thread token from HTTP form through routers, process_query, parsing, and clone_repo
  • Tests: Updated integration and unit tests to include token in form data and clone calls

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_repository_clone.py Renamed test variables to clone_config and updated assertions
tests/test_flow_integration.py Added "token": "" to all form_data entries
src/server/templates/components/git_form.jinja Inserted PAT checkbox, input field, and toggle logic
src/server/routers/index.py Accept token in form, normalize empty token to None
src/server/routers/dynamic.py Same updates as index router for catch-all paths
src/server/query_processor.py Forward token into clone_repo call
src/gitingest/query_parsing.py Extend parse_query and _parse_remote_repo to accept token
src/gitingest/entrypoint.py Pass token into parse_query
Comments suppressed due to low confidence (2)

tests/test_flow_integration.py:66

  • Consider adding test cases where a non-empty token is provided to cover the private-repo ingestion path and assert that the token is passed downstream correctly.
        "token": "",

src/gitingest/query_parsing.py:26

  • Add validation to ensure the provided token matches the expected GitHub PAT format (e.g. starts with 'github_pat_' or 'gph_') and reject or warn on invalid values.
async def parse_query(

Copy link
Member

@cyclotruc cyclotruc left a comment

Choose a reason for hiding this comment

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

Tested and works wonderfully!

added a little link to help generate a token

This PR is a big step in private repo support, until we are able to roll a proper Oauth integration

One idea for future improvement:
Store the PAT in some http only cookies so users can re-use them in subsequent visits to gitingest.com

@cyclotruc cyclotruc merged commit 3869aa3 into main Jun 21, 2025
18 checks passed
@cyclotruc cyclotruc deleted the feat/private-repo-support-ui branch June 21, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants