Commit 5390855b authored by Robert Speicher's avatar Robert Speicher

Merge branch 'add-force-push-option-to-push-branches' into 'master'

Adds --force option to push branches.

See merge request gitlab-org/gitlab-shell!167
parents 2b575a8d 2f94bc3e
v5.9.1
- Adds --force option to push branches
v5.9.0
- Support new /internal/pre-receive API endpoint for post-receive operations
- Support new /internal/post-receive API endpoint for post-receive operations
......
......@@ -116,8 +116,13 @@ class GitlabProjects
# timeout for push
timeout = (ARGV.shift || 120).to_i
# push with --force?
forced = ARGV.delete('--force') if ARGV.include?('--force')
$logger.info "Pushing branches from #{full_path} to remote #{remote_name}: #{ARGV}"
cmd = %W(git --git-dir=#{full_path} push -- #{remote_name}).concat(ARGV)
cmd = %W(git --git-dir=#{full_path} push)
cmd << forced if forced
cmd += %W(-- #{remote_name}).concat(ARGV)
pid = Process.spawn(*cmd)
begin
......
......@@ -313,6 +313,18 @@ describe GitlabProjects do
expect(gl_projects.exec).to be false
end
context 'with --force' do
let(:cmd) { %W(git --git-dir=#{full_path} push --force -- #{remote_name} #{branch_name}) }
let(:gl_projects) { build_gitlab_projects('push-branches', repos_path, project_name, remote_name, '600', '--force', 'master') }
it 'executes the command' do
expect(Process).to receive(:spawn).with(*cmd).and_return(pid)
expect(Process).to receive(:wait).with(pid)
expect(gl_projects.exec).to be true
end
end
end
describe :fetch_remote do
......
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