Commit c87f0622 authored by Valery Sizov's avatar Valery Sizov

Fix rebase for forks

parent 1da14e0d
...@@ -24,7 +24,7 @@ module MergeRequests ...@@ -24,7 +24,7 @@ module MergeRequests
) )
run_git_command( run_git_command(
%W(rebase #{merge_request.target_branch}), %W(pull --rebase #{target_project.repository.path_to_repo} #{merge_request.target_branch}),
tree_path, tree_path,
git_env.merge('GIT_COMMITTER_NAME' => current_user.name, git_env.merge('GIT_COMMITTER_NAME' => current_user.name,
'GIT_COMMITTER_EMAIL' => current_user.email), 'GIT_COMMITTER_EMAIL' => current_user.email),
......
require 'spec_helper' require 'spec_helper'
describe MergeRequests::RebaseService do describe MergeRequests::RebaseService do
include ProjectForksHelper
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) do let(:merge_request) do
create(:merge_request, create(:merge_request,
...@@ -104,6 +106,31 @@ describe MergeRequests::RebaseService do ...@@ -104,6 +106,31 @@ describe MergeRequests::RebaseService do
service.execute(merge_request) service.execute(merge_request)
end end
end end
context 'fork' do
let(:forked_project) do
fork_project(project, user, repository: true)
end
let(:merge_request_from_fork) do
forked_project.repository.create_file(
user,
'new-file-to-target',
'',
message: 'Add new file to target',
branch_name: 'master')
create(:merge_request,
source_branch: 'master', source_project: forked_project,
target_branch: 'master', target_project: project)
end
it 'rebases source branch' do
parent_sha = forked_project.repository.commit(merge_request_from_fork.source_branch).parents.first.sha
target_branch_sha = project.repository.commit(merge_request_from_fork.target_branch).sha
expect(parent_sha).to eq(target_branch_sha)
end
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment