Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You can also replace `hub` with `ingest` in any GitHub URL to access the corresp
## 📚 Requirements

- Python 3.8+
- For private repositories: A GitHub Personal Access Token (PAT). You can generate one at [https://github.com/settings/personal-access-tokens](https://github.com/settings/personal-access-tokens) (Profile → Settings → Developer Settings → Personal Access Tokens → Fine-grained Tokens)
- For private repositories: A GitHub Personal Access Token (PAT). [Generate your token **here**!](https://github.com/settings/tokens/new?description=gitingest&scopes=repo)

### 📦 Installation

Expand Down
2 changes: 1 addition & 1 deletion src/gitingest/utils/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from gitingest.utils.exceptions import InvalidGitHubTokenError

GITHUB_PAT_PATTERN = r"^(?:github_pat_|ghp_)[A-Za-z0-9_]{36,}$"
GITHUB_PAT_PATTERN = r"^(?:gh[pousr]_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9]{22}_[A-Za-z0-9]{59})$"


def is_github_host(url: str) -> bool:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
"token",
[
# Valid tokens: correct prefixes and at least 36 allowed characters afterwards
"github_pat_" + "a" * 36,
"github_pat_" + "a" * 22 + "_" + "b" * 59,
"ghp_" + "A" * 36,
"github_pat_1234567890abcdef1234567890abcdef1234",
"ghu_" + "B" * 36,
"ghs_" + "C" * 36,
"ghr_" + "D" * 36,
"gho_" + "E" * 36,
],
)
def test_validate_github_token_valid(token: str) -> None:
Expand All @@ -47,6 +50,7 @@ def test_validate_github_token_valid(token: str) -> None:
"ghp_" + "b" * 35, # one character short
"invalidprefix_" + "c" * 36, # Wrong prefix
"github_pat_" + "!" * 36, # Disallowed characters
"github_pat_" + "a" * 36, # Too short after 'github_pat_' prefix
"", # Empty string
],
)
Expand Down
Loading