diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-03-20 00:09:49 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-03-20 00:09:49 +0300 |
commit | 6e74eb4eacdc9dbb4ce584fc8ae2e151a911e17b (patch) | |
tree | cfc178ea5d99c2619e02f2e6c28326e4225a245c | |
parent | 8fd407be7e5e897b2c49c9d16d8d963913ea9abf (diff) | |
parent | 1e6ea914a1affef8490ca15338c885c11d54e17f (diff) |
Merge branch 'sh-create-branch-as-project-owner-for-github-import' into 'master'
GitHub import: Create new branches as project owner
See merge request gitlab-org/gitlab-ce!26335
3 files changed, 11 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml b/changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml new file mode 100644 index 00000000000..a3d484cbf05 --- /dev/null +++ b/changelogs/unreleased/sh-create-branch-as-project-owner-for-github-import.yml @@ -0,0 +1,5 @@ +--- +title: 'GitHub import: Create new branches as project owner' +merge_request: 26335 +author: +type: fixed diff --git a/lib/gitlab/github_import/importer/pull_request_importer.rb b/lib/gitlab/github_import/importer/pull_request_importer.rb index e294173f992..72451e5e01e 100644 --- a/lib/gitlab/github_import/importer/pull_request_importer.rb +++ b/lib/gitlab/github_import/importer/pull_request_importer.rb @@ -89,7 +89,7 @@ module Gitlab return if project.repository.branch_exists?(source_branch) - project.repository.add_branch(merge_request.author, source_branch, pull_request.source_branch_sha) + project.repository.add_branch(project.owner, source_branch, pull_request.source_branch_sha) rescue Gitlab::Git::CommandError => e Gitlab::Sentry.track_acceptable_exception(e, extra: { diff --git a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb index 15e59718dce..37c3fae7cb7 100644 --- a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb @@ -273,6 +273,11 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi mr.state = 'opened' mr.save + # Ensure the project owner 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 + importer.insert_git_data(mr, exists) expect(project.repository.branch_exists?(mr.source_branch)).to be_truthy |