fix: honor project qualifiers and repository remotes when resolving issue forks - #372
Open
mglaman wants to merge 4 commits into
Open
fix: honor project qualifiers and repository remotes when resolving issue forks#372mglaman wants to merge 4 commits into
mglaman wants to merge 4 commits into
Conversation
…tted
ProjectCommandBase checked InputInterface::hasArgument('project'), which only reports whether the argument is defined on the command, not whether the user passed it. It was always true, so the git remote fallback never ran and the null argument became an empty project name. The parsing now lives in ProjectRemote so it can be unit tested against SSH, HTTPS, and .git-less remote forms, and a missing derivation reports a clear error.
Closes #346
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ssue forks GitLab work-item ids on migrated projects share the number space with Drupal.org node ids, so a bare id can resolve to an unrelated project and build the wrong fork path. IssueProjectResolver now prefers an explicit project qualifier, then the project/<name> remote of the current repository, and only then the Drupal.org node lookup, failing loudly when the node and the repository disagree. A qualifier such as campaign#3615648 no longer triggers any Drupal.org request. Closes #359 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ork-item-fork-resolution
Drops the duplicate URL parser in src/Api/Git and moves fromRemotes() and detect() onto ProjectRemote so a single parser handles project remotes. Callers read ->machineName from the value object. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
issue:setup-remote,issue:checkout, andissue:get-forknow resolve the project that owns an issue fork through a newIssueProjectResolverinstead of callingClient::getNode()directly. An explicit qualifier (campaign#3615648,project/campaign#3615648, or a work-item URL) skips the Drupal.org lookup entirely. Inside a checkout whose remote points atproject/<name>, that project is used for bare ids and a Drupal.org node that names a different project is a hard error. The resolver never returns an empty machine name, so git never sees a-<nid>remote again.Builds on #370 — merge that first; this PR's diff shrinks to the resolver once it lands.
New helpers:
src/Api/IssueProjectResolver.php,ProjectRemote::detect()/fromRemotes()on #370'ssrc/Api/ProjectRemote.php, andWorkItemRef::projectMachineName().Why
Closes #359.
Projects that migrated to GitLab work items keep issuing iids from the same number range as Drupal.org's global node sequence.
api-d7/node/<id>either answers with a forwarding stub (now rejected by #368) or with a live, unrelatedproject_issuesuch as node 3615648 (sdx), which builtissue/sdx-3615648for acampaignwork item. Passingcampaign#3615648did not help because the qualifier was ignored and the node lookup ran anyway.How
Resolution order in
IssueProjectResolver::resolve():nidargument. No Drupal.org request.originfirst, then any remote matchinggit.drupal.org:project/<name>.gitorhttps://git.drupalcode.org/project/<name>.git). The Drupal.org node is still fetched: a missing or non-issue node falls back to the repository project, a matching project confirms it, and a different project throws a collision error that names bothcampaign#<nid>and<other>#<nid>.project#<nid>.ProjectRemote::detect()now lives insrc/Api/ProjectRemote.php, reusing fix: derive project machine name from git remote when argument is omitted #370'stryParse()for the URL matching, so only one remote-URL parser lands.Only
issue:setup-remoteandissue:checkoutpass the repository project (they mutate the repository).issue:get-forkis read-only, can run outside a checkout, and honors the qualifier only.Testing
Inside a throwaway
git clone --depth 1 https://git.drupalcode.org/project/campaign.git:🤖 Generated with Claude Code