GitHub importer fails when source/target branch is the same but from forked repository
Summary
When trying to import a repository that has a PR asking to merge from someuser:master
to our-repo:master
(same branches, different source project), you get this error message:
Validation failed: Branch conflict You can not use same project/branch for source and target
Original Zendesk ticket: https://gitlab.zendesk.com/agent/tickets/67647
What is the current bug behavior?
PR is not imported
What is the expected correct behavior?
PR gets imported :)
Relevant logs and/or screenshots
{"type":"pull_request","url":"https://api.github.com/repos/user/repo/pulls/123","errors":"Validation failed: Branch conflict You can not use same project/branch for source and target"}
Possible fixes
We can solve this by changing how the branch_names are generated by the pull_request_formatter.rb
.
My suggestion is to add the user/repo
to the disambiguation strategy that users pull/#{number}/#{source_branch_ref}
, so it becames: pull/#{number}/#{user}/#{repo}/#{source_branch_ref}
Related #15596 (closed)