Include MR version information when loading file diffs
What does this MR do and why?
For #34643 (closed)
The bulk of the logic of why the code is the way it is is documented in the first commit.
Problem
The problem is basically that MR Changes view doesn't take the diff_id
or start_sha
into account when requesting a single-file diff, which is what happens when a diff is collapsed.
If a diff is collapsed and the user is looking at an MR "version" other than BASE
=>HEAD
, they will receive the wrong diff.
Solution
We don't really have a great way to get the diff_id
or start_sha
when expanding a file.
Neither value is included directly in either the representation of the file itself OR the MR metadata.
However, the MR metadata does have a collection of other URLs, which should always include the version_path
(even for "default" views that are not previous versions).
The version_path
includes the diff_id
and start_sha
, so the fix here is to extend our utility function that derives MR info from a path to also derive the version information.
This introduces many cases where the version information returned by the MR information derivation function will be blank (since many paths don't include the necessary info), but this shouldn't be harmful.
Finally, once the information is derived from the version_path
, it's included in the parameters of the loadCollapsedDiff
request.
Notes
diff_id
and start_sha
are in the URL, but the MR metadata paths are the authoritative sources of URLs, so I immediately discarded the idea of pulling these values from the browser location bar.
Screenshots or screen recordings
Before | After |
---|---|
mr-version-diff-before | mr-version-diff-after |
How to set up and validate locally
- Please refer to the linked issue to see replication steps (and a demo MR)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Merge request reports
Activity
changed milestone to %15.7
assigned to @thomasrandolph
1 Warning This merge request changed files with disabled eslint rules. Please consider fixing them. Disabled eslint rules
The following files have disabled
eslint
rules. Please consider fixing them:app/assets/javascripts/diffs/store/actions.js
Run the following command for more details
node_modules/.bin/eslint --report-unused-disable-directives --no-inline-config \ 'app/assets/javascripts/diffs/store/actions.js'
Reviewer roulette
Changes that require review have been detected!
Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:
Category Reviewer Maintainer frontend Dheeraj Joshi (
@djadmin
) (UTC+5.5, 12.5 hours ahead of@thomasrandolph
)Frédéric Caplette (
@f_caplette
) (UTC-5, 2 hours ahead of@thomasrandolph
)To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
DangerBundle size analysis [beta]
This compares changes in bundle size for entry points between the commits 618df5ad and dec57acc
Special assetsEntrypoint / Name Size before Size after Diff Diff in percent average 3.51 MB 3.51 MB - 0.0 % mainChunk 1.95 MB 1.95 MB - 0.0 %
Note: We do not have exact data for 618df5ad. So we have used data from: 086f1497.
The intended commit has no webpack pipeline, so we chose the last commit with one before it.Please look at the full report for more details
Read more about how this report works.
Generated by
Dangeradded 1 commit
- 2d5aa415 - Test that diffs load with the correct version info
marked the checklist item I have evaluated the MR acceptance checklist for this MR. as completed
added bugfunctional label
- Resolved by Thomas Randolph
Hey @leetickett-gitlab would you mind starting an FE review here?
If you can't get to this, please send it back to me!
If you're okay with it, please send it to either@iamphill
(domain expert) or whoever roulette suggests for maintainer (currently@cngo
).Thanks!
requested review from @leetickett-gitlab
added workflowin review label and removed workflowin dev label
requested review from @cngo and removed review request for @leetickett-gitlab
@leetickett-gitlab
, thanks for approving this merge request.This is the first time the merge request is approved. To ensure full test coverage, a new pipeline will be started shortly.
For more info, please refer to the following links:
added pipeline:mr-approved label
Allure report
allure-report-publisher
generated test report!e2e-review-qa:
test report for dec57accexpand test summary
+-----------------------------------------------------------------------------------------+ | suites summary | +------------------------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Manage | 39 | 0 | 4 | 6 | 43 | ❗ | | Plan | 49 | 0 | 1 | 0 | 50 | ✅ | | Govern | 15 | 0 | 5 | 3 | 20 | ❗ | | Verify | 12 | 0 | 1 | 0 | 13 | ✅ | | Create | 28 | 0 | 1 | 0 | 29 | ✅ | | Configure | 0 | 0 | 1 | 0 | 1 | ➖ | | Feature flag handler sanity checks | 9 | 0 | 0 | 0 | 9 | ✅ | | Version sanity check | 0 | 0 | 1 | 0 | 1 | ➖ | | Package | 0 | 0 | 1 | 0 | 1 | ➖ | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Total | 152 | 0 | 15 | 9 | 167 | ❗ | +------------------------------------+--------+--------+---------+-------+-------+--------+
- Resolved by Thomas Randolph
added 1 commit
- dec57acc - Use `.toMatchObject` instead of `objectContaining`
- Resolved by Coung Ngo
Thanks for the review @cngo!
I updated the Jest assertions in this commit.
Could you take another look?
mentioned in issue thomasrandolph/todo#8 (closed)
enabled an automatic merge when the pipeline for 6a983e65 succeeds
mentioned in commit 5c5b2742
added workflowstaging-canary label and removed workflowin review label
added workflowcanary label and removed workflowstaging-canary label
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
added releasedcandidate label
added releasedpublished label and removed releasedcandidate label