Working on somebody else's merge request
Reading a contribution and changing one are different jobs, and they use
different commands. check and review answer “is this good?”. This page is
the other half: taking a merge request that is nearly right, or deliberately
incomplete, and finishing it.
The worked example is the one that prompted this page, and it is the commonest shape in contrib maintenance:
The Project Update Bot has opened a merge request for Drupal 12 compatibility. It fixes the code but does not touch
core_version_requirement, so nothing can actually be tested against core 12 yet. I want to add that, verify it, and push it back to the bot’s merge request.
Why check is not the way in
Section titled “Why check is not the way in”check and review fetch refs/merge-requests/<iid>/merge onto a branch
called mr-<iid>. That is exactly right for producing a verdict and exactly
wrong for working:
- It is force-updated on every apply, so a commit on it is a commit waiting to be destroyed.
publishrefuses it, for the same reason.- It is the merge tree — the contribution merged into the current tip of its target — which is a tree that exists on neither side and cannot be pushed anywhere.
What you want is the merge request’s own source branch, which on
drupal.org lives on an issue fork rather than on the project. checkout
gets it.
The loop
Section titled “The loop”upkeep checkout jumplinks 1 --version=12That resolves which fork the branch is on, adds the remote that pushes back to it, fetches the branch and checks it out — then tells you the two commands you will want next:
Environment upkeep-jumplinks-d12 Branch project-update-bot-only Module path /…/upkeep-jumplinks-d12/module
Check it as you work: upkeep check jumplinks --working-copy --version=12 Send the work back: upkeep publish jumplinks 3628056 --branch project-update-bot-only --version=12publish works out which environment holds the branch, so --version is
optional there and only needed to break a tie. The others still default the
core to the first entry in the module’s core_versions, and modules:track
appends — precisely so adding core 12 does not silently retarget your bare
upkeep check — so a module tracking ["11", "12"] defaults to 11 while you
work in the 12 environment. Pass --version to check and env:path or they
will look in the wrong directory.
The issue node id and the branch name are printed because you have no reason to know either and every reason to mistype them.
Now edit the module — it is an ordinary git checkout at the module path — and iterate locally, with no push and no merge request in the way:
upkeep check jumplinks --working-copy --version=12--working-copy runs the whole suite against whatever the working copy holds.
It needs no merge request, no token, and it caches nothing: every other
verdict is keyed by a subject and a revision so staleness is detectable, and a
working copy has neither.
When it passes, commit and push it back:
cd "$(upkeep env:path jumplinks --version=12)/module"git commit -am "Declare Drupal 12 compatibility"cd -upkeep publish jumplinks 3628056 --branch project-update-bot-onlypublish reports which environment it published from — it looks for the one
whose working copy is on the branch rather than guessing a core. If the same
branch is checked out in two of them it refuses and asks you to name one with
--version, because they may hold different commits and the wrong ones would
go to a live merge request.
publish finds the merge request already open on that branch and reports
“Updated the open merge request for this branch: !1”. It never opens a second
one.
And now the thing you could not do at the start:
upkeep check jumplinks 1 --version=12This works because the core check reads the merge request’s own tree, not
the branch it targets — so the ^12 you just added is what it sees.
Why checkout does not check the core
Section titled “Why checkout does not check the core”Every other merge-request command refuses a core the code does not declare, because gathering evidence against an unsupported core produces failures that say nothing about the contribution.
checkout deliberately does not ask. The reason to take over a merge
request is frequently that it does not support the core yet — that is the
work. Refusing to check out the branch because the branch lacks what you are
about to add would be the tool declining its own purpose. check asks the
question, at the point a verdict is produced, where it means something.
For the same reason, upkeep dev <module> --version=12 will provision an
environment for a core the module does not declare. The module is linked into
the site rather than installed as a composer package, so its own
drupal/core constraint is not imposed on the site.
Nothing here resets anything
Section titled “Nothing here resets anything”checkout is safe to re-run. An existing local branch of that name is
checked out as it stands — it may hold commits that exist nowhere else, and
discarding those is precisely what the managed mr-<iid> branch does and this
command does not. If you want the fork’s version of it, move your own commits
aside first; upkeep will not do it for you.
A dirty working copy is refused before anything is fetched, naming what is uncommitted.
What you need, and what you do not
Section titled “What you need, and what you do not”| Checking out the branch | nothing. The fork is fetched over anonymous HTTPS |
| Running checks | nothing |
| Pushing it back | an SSH key, and push access to the issue fork |
upkeep never hands git a password or a token — publish pushes over SSH to a
URL GitLab itself supplies. A HTTP Basic: Access denied means something tried
to push over HTTPS; a personal access token will not fix it.
Two push refusals need opposite answers, and upkeep tells them apart:
- GitLab does not know you — your SSH key. Add one at
git.drupalcode.org SSH keys,
then
ssh -T git@git.drupal.organdssh-add -l. - GitLab knows you and says no — push access. On drupal.org, creating an issue fork does not grant push access to it; that is a separate button on the issue page. If the fork is somebody else’s and you are not a maintainer, the access is theirs to give.
When the branch is on the project itself
Section titled “When the branch is on the project itself”Both shapes work. A branch on an issue fork is what drupal.org’s issue queue produces — the issue page mints the fork, and a contributor has no write access to the project. Measured on pathauto, 100 of 100 open merge requests came from a fork.
A project whose issues live in GitLab has no such step, so a maintainer
pushes branches straight to the canonical repository. On helper, four of five
open merge requests are same-project. checkout handles those too: it adds
a canonical remote carrying the SSH URL GitLab advertises, and the report
tells you to push rather than naming publish — there is no issue fork to
publish against, and the merge request is already open on the branch, so the
push updates it.
origin is untouched in both cases: HTTPS and anonymous, so the fetch needs no
key.
If the merge request does not say where its branch is at all, the command refuses rather than guessing — check it out with git, or start the work as your own contribution:
upkeep start <module> <issue> # your own branch, cut from a fresh baseupkeep publish <module> <issue> # pushed to your issue fork, opened as an MRThat is the other entry point, and it is the right one when you are not continuing somebody’s existing work. See Work on an issue.