Skip to content

fix: scope mr:list to the issue fork instead of the whole parent project - #365

Merged
mglaman merged 1 commit into
mainfrom
mr-list-issue-fork-scope
Aug 28, 2026
Merged

fix: scope mr:list to the issue fork instead of the whole parent project#365
mglaman merged 1 commit into
mainfrom
mr-list-issue-fork-scope

Conversation

@mglaman

@mglaman mglaman commented Aug 28, 2026

Copy link
Copy Markdown
Owner

What changed

mr:list <nid> now returns only MRs opened from the issue's fork. An issue with no fork or no MRs returns an empty list instead of every open MR on the parent project. mr:status and mr:logs auto-selection uses the same scoped list, so they no longer pick an unrelated MR when mr-iid is omitted.

Closes #364. Reported by @tedbow.

Why

#314 moved mr:* resolution from issue/{name}-{nid} to project/{name} because MR IIDs belong to the target project. That was right for mr:diff/mr:status/mr:logs, but mr:list inherited it and lost its issue scope: drupalorg mr:list 3591850 returned !16891, !16890, ... from project/drupal, none related to the issue.

How

GitLab's GET /projects/:id/merge_requests only returns MRs targeting that project, so listing on the fork returns []. The action keeps querying the parent project and adds source_project_id={fork id}:

GET /projects/project%2Fdrupal/merge_requests?state=opened&source_project_id=241716
  • Fork 404 → empty MergeRequestListResult, no MR request made. Other GitLab errors propagate.
  • MergeRequestListResult gains issueFork (issue_fork in JSON, <issue_fork> in llm, a line in md). It is null for project-wide lists (mr:list project/drupal), which stay unchanged.
  • ListMergeRequestsAction accepts an optional $projectMachineName, mirroring GetIssueForkAction, so WorkItemRef input (project/ai_context#3586157) skips the Drupal.org node lookup.
  • Skill docs state the scoping rule and how to get a project-wide list.

Testing

  • vendor/bin/phpcs src tests, vendor/bin/phpstan analyse src, vendor/bin/phpunit (167 tests) all pass.
  • Live against git.drupalcode.org:
    • mr:list 3591850No opened merge requests found for issue fork issue/drupal-3591850. (fork exists, zero MRs)
    • mr:list 3619614 → only !16890
    • mr:list 'project/ai_context#3586157' --state=all → only !141, no Drupal.org request
    • mr:list project/drupal → project-wide, issue_fork: null
    • mr:status 3619614 -n → auto-selects !16890

🤖 Generated with Claude Code

mr:list <nid> listed every MR on project/{name}, so an issue with no MRs
returned unrelated project MRs. mr:status and mr:logs auto-selected from
that same list.

GitLab only lists MRs on their target project, so the parent project is
still queried but now filtered with source_project_id set to the issue
fork. A missing fork returns an empty list. The result carries an
issue_fork field so output shows which scope produced the list.

Closes #364

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mglaman
mglaman merged commit ff90e18 into main Aug 28, 2026
9 checks passed
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.

mr:list <nid> lists all parent-project MRs instead of the issue fork's MRs

1 participant