GitHub importer: Use the project creator to create branches from forks
The project owner may actually be a group, in which case the branch creation would fail due to a lack of username. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59396
This commit is contained in:
parent
09d25b04c3
commit
d0336ae88f
3 changed files with 9 additions and 4 deletions
5
changelogs/unreleased/sh-fix-github-import-creator.yml
Normal file
5
changelogs/unreleased/sh-fix-github-import-creator.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: 'GitHub importer: Use the project creator to create branches from forks'
|
||||
merge_request: 26510
|
||||
author:
|
||||
type: fixed
|
|
@ -89,7 +89,7 @@ module Gitlab
|
|||
|
||||
return if project.repository.branch_exists?(source_branch)
|
||||
|
||||
project.repository.add_branch(project.owner, source_branch, pull_request.source_branch_sha)
|
||||
project.repository.add_branch(project.creator, source_branch, pull_request.source_branch_sha)
|
||||
rescue Gitlab::Git::CommandError => e
|
||||
Gitlab::Sentry.track_acceptable_exception(e,
|
||||
extra: {
|
||||
|
|
|
@ -273,10 +273,10 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
|
|||
mr.state = 'opened'
|
||||
mr.save
|
||||
|
||||
# Ensure the project owner is creating the branches because the
|
||||
# Ensure the project creator is creating the branches because the
|
||||
# merge request author may not have access to push to this
|
||||
# repository.
|
||||
allow(project.repository).to receive(:add_branch).with(project.owner, anything, anything).and_call_original
|
||||
# repository. The project owner may also be a group.
|
||||
allow(project.repository).to receive(:add_branch).with(project.creator, anything, anything).and_call_original
|
||||
|
||||
importer.insert_git_data(mr, exists)
|
||||
|
||||
|
|
Loading…
Reference in a new issue