Repository navigation
feat(gitlab): infer issue context from native branch prefixes - #4911
IsmaelMartinez merged 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The GitLab branch issue-inference change has no active review issues blocking approval.
No open issues 🎉
What changed in this PR
Adds GitLab-native branch issue inference to PR-Agent’s ticket-context extraction, allowing same-project merge requests to use issue context without repeating references in their title or description.
Changes:
- Recognizes
<IID>-...GitLab branches while preserving description → title → branch precedence, deduplication, and existing ticket limits. - Excludes fork MRs and nested branch patterns; applies visibility and confidentiality checks to branch-only references.
- Adds focused tests and updates documentation, clarifying that custom
branch_issue_regexremains GitHub-only.
| File | Description |
|---|---|
tests/unittest/test_ticket_extraction_async.py |
Adds coverage for branch eligibility, precedence, deduplication, opt-out, and visibility boundaries. |
pr_agent/settings/configuration.toml |
Updates setting comments to describe GitLab support and GitHub-only regex customization. |
pr_agent/commands/ticket_pr_compliance_check.py |
Implements GitLab branch inference, project-alias deduplication, and visibility safeguards. |
docs/docs/usage-guide/configuration_reference.md |
Synchronizes configuration descriptions with the updated setting comments. |
docs/docs/core-abilities/fetching_ticket_context.md |
Documents supported branch patterns, source precedence, and privacy restrictions. |
Review effort: Balanced
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
⚙️ Agent run details
|
PR Code Suggestions ✨Explore these optional code suggestions:
⚙️ Agent run details
|
7be58c6 to
e1555ee
Compare
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for the thorough work and tests; I ran them and the branch-only handling held: confidential and members-only issues are skipped, forks and nested branch names are not inferred. Holding this one for now. One ask: once #4919 lands with the #4908 rule (skip confidential issues in the own project, explicit references included), rebase onto it and drop the explicit-reference carve-out and its test, since this PR currently keeps own-project confidential issues for explicit references. The hold is about order, not the code.
|
Thanks for the review and for confirming the branch-only safeguards! Agreed on the sequencing. Once #4919 is merged, I'll rebase this PR onto the updated main, remove the explicit-reference carve-out and its dedicated test, and rely on the shared confidentiality handling from #4919 for explicit references. The stricter safeguards for branch-inferred issues will remain in place, with any affected tests and documentation updated as needed before rerunning the relevant checks. |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for the update. #4932, #4959 and #4919 are now in main, so this needs the rebase you described. Two asks: drop the explicit-reference carve-out so confidential own-project issues are skipped via #4919, and give the branch-prefix path the same date exception as #4959 (2026-11-15 is not an issue number; 2024-upgrade-deps, feature/42-2026-11-15 and 2026-11/123-fix keep their documented behaviour). Keeping the label until then.
Use native same-project GitLab branch prefixes to resolve issue context without requiring duplicate references in MR descriptions. Preserve explicit issue precedence, visibility checks, and existing ticket limits. Document GitLab's ASCII issue-ID, no-leading-zero, and date-prefix rules alongside the shared branch-extraction setting.
e1555ee to
3799eff
Compare
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for the rebase and for dropping the carve-out. I ran it: a confidential own-project issue is skipped for branch-only and explicit references, 2026-11-15, 2026-11/123-fix and feature/42-2026-11-15 are not inferred, and 2024-upgrade-deps still is. The full unit suite passes and CI is green.
User description
Why
GitLab automatically links issues to merge requests when the source branch starts with an issue IID followed by a hyphen, such as
123-fix-export.However, PR-Agent currently extracts GitLab issue references only from MR descriptions and titles. Users following GitLab's native branch naming convention must repeat the issue reference manually to make its context available to PR-Agent.
This enhancement allows PR-Agent to recognize those existing branch references without requiring additional user input.
GitLab documentation: https://docs.gitlab.com/user/project/repository/branches/
Changes
<IID>-, where the IID contains 1–6 digits and is greater than zero.feature/123-fixare excluded.extract_issue_from_branchsetting, including consistent interpretation of string-form boolean values such as"false"across GitHub and GitLab.branch_issue_regexsetting remains GitHub-only.Examples
123-fix-export123-fix-export123-fix-exportfeature/123-fix123-fix-export123-fix-exportCompatibility and cost
extract_issue_from_branchsetting.Tests
Regression coverage uses the existing ticket extraction flow and mocked Git provider API responses, including:
The changes are limited to the existing ticket extraction logic, relevant tests, and documentation.
PR Type
Enhancement, Tests, Documentation
Description
Infer GitLab issues from same-project branch prefixes.
Enforce visibility and confidentiality for implicit references.
Preserve reference precedence, deduplication, and lookup limits.
Document settings and add focused regression coverage.
Diagram Walkthrough
File Walkthrough
ticket_pr_compliance_check.py
Infer GitLab branch issues with visibility safeguardspr_agent/commands/ticket_pr_compliance_check.py
one-to-six-digit IID followed by a hyphen.
respecting the existing setting and lookup limit.
while preserving explicit-reference behavior.
and exclude confidential implicit issues.
test_ticket_extraction_async.py
Cover GitLab branch inference and security boundariestests/unittest/test_ticket_extraction_async.py
inference opt-out.
project aliases.
explicit references.
fetching_ticket_context.md
Document GitLab branch linking rules and safeguardsdocs/docs/core-abilities/fetching_ticket_context.md
reference precedence.
the metadata request.
support.
configuration_reference.md
Update branch issue configuration reference descriptionsdocs/docs/usage-guide/configuration_reference.md
extract_issue_from_branchdocumentation to include same-projectGitLab inference.
branch_issue_regexexplicitly GitHub-only and link to detaileddocumentation.
configuration.toml
Clarify branch inference settings without changing defaultspr_agent/settings/configuration.toml
comment.
detailed documentation.
⚙️ Agent run details