Skip to content

Fix importer for GitHub Pull Requests when a branch was reused across Pull Requests

username-removed-283999 requested to merge gh-pull-requests into master

Closes #17766 (closed)

What does this MR do?

GitHub importer fails when a repository has two Pull Requests, with the same branch name and different SHA, one of which was closed without merging, and one which is open or was merged in. This happens because we only checks if the branch exists in the Gitlab::GithubImport::BranchFormatter#exists?, before creating the missing references on Github. With this MR we check if both branch, and SHA exists in the current project. If no, we create the missing reference on GitHub before import the PR.

Are there points in the code the reviewer needs to double check?

Nope.

Why was this MR needed?

Github importer will fail if branch was reused across Pull Requests.

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/19439

/cc @royaldark @thomasjachmann

Merge request reports