-
Notifications
You must be signed in to change notification settings - Fork 25
Add GitLab support #424
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
Add GitLab support #424
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Classes defined inside methods/loops are inefficient as they get redefined on each call. Moved all helper classes (IssueLike, IssueAsPR, CommitWrapper, BranchWrapper, etc.) to module level with descriptive names. Also replaced generic single-letter class names (R, C, B, T, Z, O) with descriptive names like _GitRef, _CommitWithTree, _Blob, etc. for better debuggability.
GitLab does not have an equivalent to GitHub's repository_dispatch API. Add a no-op method that logs a warning to prevent AttributeError when TagBot tries to call this method on a GitLab repository.
Previously, unknown states like 'all' were passed directly to GitLab, which only accepts 'opened' or 'closed'. Now only valid states are mapped, and 'all' or unknown values result in no state filter (returning all issues).
- Move logging import to module level - Add labels attribute to _IssueAsPR and _PRFromMR for consistency - Filter merged MRs by 'since' parameter in get_issues() - Remove unnecessary forward reference quotes on _BranchCommit
- Add tests for private, full_name, ssh_url, html_url properties - Add tests for get_branches, get_git_ref, get_git_tag, get_branch - Add tests for get_commits, create_git_release (including draft error) - Add test for create_repository_dispatch warning - Add test for get_contents raw content fallback - Test that labels are passed through on issues and MRs - Fix mutable default argument in test_repo_gitlab.py
35095dd to
e712c6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds GitLab support to TagBot, enabling it to work with repositories hosted on GitLab in addition to GitHub. The implementation provides a pragmatic subset of the PyGithub API by wrapping python-gitlab functionality.
Key changes:
- New GitLab wrapper module that implements a PyGithub-compatible interface for GitLab
- Automatic detection of GitLab hosting via URL patterns and dynamic client initialization
- Optional python-gitlab dependency with graceful fallback and clear error messaging
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tagbot/action/gitlab.py | New module implementing PyGithub-compatible wrappers around python-gitlab API for repositories, pull requests, issues, commits, releases, and file contents |
| tagbot/action/repo.py | Modified to detect GitLab URLs and instantiate GitlabClient instead of Github; updated exception handling to support both GitHub and GitLab exception types |
| test/action/test_repo_gitlab.py | Tests for GitLab client initialization and detection logic |
| test/action/test_gitlab_wrapper.py | Basic tests for GitLab wrapper functionality including file contents, pull requests, and branch operations |
| test/action/test_gitlab_wrapper_extended.py | Comprehensive tests covering releases, issues, commits, branches, git refs, and error conditions |
| pyproject.toml | Declares python-gitlab as an optional extra dependency for GitLab support |
| README.md | Documents GitLab support configuration with example workflow inputs and usage notes |
| .gitignore | Adds .venv/ to ignore virtual environment directories |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add python-gitlab as optional dependency in pyproject.toml - Add type annotations to GitLab wrapper classes (_CommitWrapper, _CommitWithTree) - Remove unnecessary cast() calls in repo.py - Add comment to empty except clause - Update poetry.lock - Use modern poetry group syntax for dev dependencies
45073df to
613e497
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add body property to _PR class (required by repo.py line 306) - Add closed_at to _IssueAsPR class (required by changelog.py line 131) - Document that lazy parameter is ignored in get_repo - Simplify README GitLab feature description
|
@arnavk23 can you review this please. I think it should be good to go. |
I've looked this through already. Thanks for all the help. It is good to go. |
I asked Claude to polish up #422
fyi @arnavk23