Improve GitHub import performance
What does this MR do?
- This adds
fetch
config to automatically maprefs/pull/*/head
torefs/merge-requests/*/head
. The benefit is that we fetch all the refs at the beginning instead of fetching individual refs when creating each MR. - This originally changed the temp branch names to not include a
/
as this would create the ref in a subfolder inrefs/heads
(e.g.refs/heads/gh-123/456/rymai/foo
), and would leave empty directories upon branch deletion (e.g.refs/heads/gh-123/456/rymai/
). - That said, now we don't create temporary branches since we don't actually need them for the import:
- We set the
source_branch_sha
,target_branch_sha
, andref_fetched: true
in theMergeRequest
record - After a
MergeRequest
record is created, aMergeRequestDiff
is generated: we don't have to fetch the ref since we've mapped therefs/pull
refs torefs/merge-requests
so we know for sure we can generate a diff, hence that's why we've setref_fetched: true
directory in theMergeRequest
record
- We don't check if the source or target branch actually exists (i.e. in
refs/heads
) since that doesn't change anything for creating theMergeRequest
orMergeRequestDiff
records! If the source branch exists, well it will be displayed with a link in the MR widget, otherwise, no link. - When the source project is not the same as the target project, we prepend the source branch name with
<user>:
to mimic how we display branches from fork in the MR widget
Are there points in the code the reviewer needs to double check?
Why was this MR needed?
To improve the performance of the GitHub import.
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug - Review
-
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together
What are the relevant issue numbers?
Closes #36288 (closed), #36292 (closed), #38467 (closed).
Edited by Rémy Coutable