Repository navigation
Say in the PR preview where a ticket's edits go while the PR is checked out - #674
huzaifaalmesbah wants to merge 2 commits into
Conversation
…ed out Checking out a pull request from a ticket with edits parks them in the ticket branch's WIP commit and takes them out of the files, and the preview said nothing of it: the edits looked destroyed. git:preview-pr now counts the ticket's edits the way its card does, against the branch point, and the preview says "Your edits to N files stay with ticket #X and come back when you revert this PR". When revert goes elsewhere, because the PR was first tried from another ticket, it says they come back when you return to the ticket instead of promising revert does it. The count only feeds that sentence, so a ticket branch with no recorded branch point previews without it rather than failing. Fixes WordPress#672.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This conflicts with trunk since #702 (the "could not download the latest trunk" note, #701). Both changes touch the same lines, and the fix is to keep both:
I merged trunk locally this way and the full unit suite passes. Could you merge or rebase onto trunk and push? |
…icket-edits # Conflicts: # src/main.js # src/renderer/index.jsx # src/renderer/pr-checkout.cjs # tests/unit/apply-card.test.cjs # tests/unit/ipc-wiring.test.cjs
|
Thanks, @ryanwelcher! I merged trunk in f132bad and resolved the conflicts the way you described, so both |
Why
Applying a pull request to a ticket that has your own edits makes those edits disappear from the checkout. Nothing in the preview says where they go, so it looks like the app destroyed them (#672). They are safe: the switch to
pr/Nparks them in the ticket branch's "Work in progress" commit, and Revert this PR brings them back. The contributor just isn't told before clicking Apply and rebuild.What changes
The Apply PR #N preview now says where the edits go, before they go:
git:preview-prnow also returnssetAside: { ref, files }when the current branch is a ticket or issue branch. The count comes fromcollectUnsubmittedFiles, measured from the branch point with the parked WIP included. That is the same number the ticket card's changes note shows, and exactly what the checkout takes out of the files.describePrPreviewturns it into the sentence (ticket or issue, singular or plural). It says nothing when there are no edits or the preview is from trunk.recordPrHeadkeeps thereturnTofrom the first time a PR was tried. If PR First stab at supporting Gutenberg projects #7 was first tried from ticket A and is now tried from ticket B, Revert this PR returns to A. In that case the sentence says the edits "come back when you return to it" and does not promise revert.Not changed: the banner after checkout. The issue asks for the "PR #N is applied" banner to repeat where the edits are. It already does:
describePrCheckoutgives it "Your ticket changes are saved separately and return when you revert this PR.", andgutenberg-site.spec.jsasserts that line is visible for issues. So this PR leaves the banner alone. The renderer still doesn't readparkedfrom the checkout result, because nothing needs it now.How to test this
Platforms: any. Nothing here depends on the platform.
The reported path is covered by a journey:
npx playwright test --project=journeys tests/e2e/journeys/pr-checkout.spec.js -g "keeps ticket work". It links ticket 60001, edits a file, opens the preview for PR #7, and now asserts the sentence before clicking Apply and rebuild. I ran it against trunk'ssrc/and it fails on exactly that assertion. It passes on this branch.By hand, on a real
wordpress-developsite (what the journey cannot reach):Starting state: a site with a linked ticket.
src/wp-admin/css/install.css.install.cssno longer has your edit, and the banner says the ticket changes are saved separately.install.cssis back.What must not have happened:
Risks and limitations
wordpress-developcheckout.wordpress-developclone. The journey uses the app's fake site and origin.Related
Fixes #672
Design decisions and alternatives considered
worktreeDirty. The card's count is already in renderer state and would avoid a walk. But it can benullwhile a probe runs, or stale after a switch. The preview is a decision point, so it counts at the moment it is shown. The number is the same either way, because both come fromcollectUnsubmittedFiles.returnTois the current ticket. Rather than make the preview wrong in that case, it says something true in both.Review outcome (required — see AGENTS.md)
1 [fix here] · 0 [follow-up]. Fixed: 1 of 1.
[fix here] The preview could fail where it used to succeed.
collectUnsubmittedFilesthrows throughpatchBaseOidwhen the ticket branch has no recordedbaseOid, which is reachable through migration and through linking an existing branch. The preview would then show the raw error and block applying any PR. Fixed: the count is optional (the same pattern as the discard handlers), and the new ipc-wiring testgit:preview-pr still previews from a ticket branch with no recorded branch pointfails without the fix.Review: completed. A fresh subagent did the judgement pass against
.github/instructions/code-review.instructions.mdon the working tree over basetrunk@ 7ee3ead. It checked the count's correctness, thatreturnToagrees withgit:checkout-pr, the "Return to saved copy" path, performance, i18n, cross-platform and test layers.npm run lintclean;npm test2101 pass / 0 fail / 2 skipped; journeyspr-checkout.spec.js,gutenberg-site.spec.js,apply-card.spec.jspass.Since review: the [fix here] above and its test were applied before committing (head adb4165). Re-ran lint,
npm testand the PR journeys on it. No other change.Implementation notes
src/main.js:git:preview-prreturnssetAside.src/renderer/pr-checkout.cjs:setAsideSentenceanddescribePrPreview({ setAside, returnTo, noun })givesetAsideNote. The four strings use_nwith positional placeholders and translator comments.src/renderer/apply-card.cjsandcomponents/apply-card.jsx:previewWordscarriessetAsideNote, and the dialog shows it under the file list.pr-checkout-renderer.test.cjs(wording: ticket, issue, singular, revert elsewhere, none),apply-card.test.cjs(carried throughpreviewWords),ipc-wiring.test.cjs(count against the branch point, null on trunk, no branch point), andpr-checkout.spec.js(the reported path).Screenshots or recording
The Apply PR #7 dialog from the
pr-checkout.spec.jsjourney, with ticket 60001 and one edited file.