Skip to content

Improve GitHub import performance

What does this MR do?

  1. This adds fetch config to automatically map refs/pull/*/head to refs/merge-requests/*/head. The benefit is that we fetch all the refs at the beginning instead of fetching individual refs when creating each MR.
  2. This originally changed the temp branch names to not include a / as this would create the ref in a subfolder in refs/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/).
  3. 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, and ref_fetched: true in the MergeRequest record
  • After a MergeRequest record is created, a MergeRequestDiff is generated: we don't have to fetch the ref since we've mapped the refs/pull refs to refs/merge-requests so we know for sure we can generate a diff, hence that's why we've set ref_fetched: true directory in the MergeRequest record
  1. 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 the MergeRequest or MergeRequestDiff records! If the source branch exists, well it will be displayed with a link in the MR widget, otherwise, no link.
  2. 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?

What are the relevant issue numbers?

Closes #36288 (closed), #36292 (closed), #38467 (closed).

Edited by username-removed-128633

Merge request reports