Backfill `squash_commit_sha` for existing merge requests
Main issue: #21686 (closed)
Problem
After #21686 (closed) was done, we'll start displaying a link to the original merge request for squash and merge commits. However, it will work only for future merge requests.
Squashed commits and/ MRs before 2021-01-11 11:07 UTC on gitlab.com or upgrading GitLab to %13.8 or later on self-managed)) do not show the related MR(s) for it even after !49968 (merged) !50178 (merged).
We want to backfill squash_commit_sha
for already merged merge requests.
In the following MRs in www-gitlab-com as well as many MRs in gitlab-org/gitlab still do not show related MRs:
-
gitlab-com/www-gitlab-com@a4b4ae46
- shows
No related merge requests found
-
!7218
is shown as related MR
- shows
-
gitlab-com/www-gitlab-com@8de75fcb
- shows
No related merge requests found
-
!15502
is shown as related MR
- shows
Note
A workaround for this has exists before/after gitlab-foss!13713 (merged) (gitlab-foss#2383 (closed)) (%10.5) with Git and third-party tools.
!1024 (merged) (#150 (closed)) (%8.17) introduced this feature.
cf. #21686 (closed) (dup #211608 (closed)) (%13.8)
Proposal
We need to investigate and find a way to fetch squash commit sha and connect it to the correct merge request.
As one of the option, we can try to get the last parent of the merge commit.
if merge_request.squash?
squash_commit_sha = merge_request.merge_commit.parents.last
end
However, I expect possible edge cases with this approach. 0