Suggestions: use template from target project instead of source project
What does this MR do and why?
Fixes #354880 (closed).
For MRs created from fork projects with different suggestion template than target project, there is currently a discrepancy in commit message. Frontend shows values from target project, however the actual commit ends up with values from source project (fork). It uses source project's template, and variables %{project_name}
and %{project_path}
also use values from source project.
This MR fixes that - suggestions will now use target's project template, and variables %{project_name}
and %{project_path}
will use target's project name and path as well.
Screenshots or screen recordings
Target project setting:
Preview:
Result commit BEFORE my changes:
AFTER:
Note: there is still an unrelated discrepancy in %{project_path}
(it uses path with namespace in frontend preview, but path without namespace in end result) - I've addressed it in a comment.
How to set up and validate locally
- Create or find a project and fork of the project.
- Change template in target project - https://docs.gitlab.com/ee/user/project/merge_requests/reviews/suggestions.html#configure-the-commit-message-for-applied-suggestions - to different than source project. It could also use
%{project_name}
variable. - Create a MR from fork to main project.
- Add a comment with suggestion.
- Verify that end commit is the same as shown in preview, and that it uses target's project.
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.