Commit 91e72255 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'gl_ee_issue_116' into 'master'

Add new required commands to update remote mirrors

Closes gitlab-org/gitlab-ee#116

See merge request !43
parents 9f482f8d 42caddb2
Pipeline #654 skipped
v2.6.13
- Add push-branches command
- Add delete-remote-branches command
v2.6.12
- Fix git-annex issue not working using custom SSH port repositories
......
......@@ -61,6 +61,8 @@ class GitlabProjects
when 'fork-project'; fork_project
when 'fetch-remote'; fetch_remote
when 'update-head'; update_head
when 'push-branches'; push_branches
when 'delete-remote-branches'; delete_remote_branches
when 'gc'; gc
else
$logger.warn "Attempt to execute invalid gitlab-projects command #{@command.inspect}."
......@@ -71,6 +73,47 @@ class GitlabProjects
protected
def push_branches
remote_name = ARGV.shift
$logger.info "Pushing branches from #{full_path} to remote #{remote_name}: #{ARGV}"
cmd = %W(git --git-dir=#{full_path} push --tags -- #{remote_name}).concat(ARGV)
pid = Process.spawn(*cmd)
begin
Process.wait(pid)
$?.exitstatus.zero?
rescue => exception
$logger.error "Pushing branches to remote #{remote_name} failed due to: #{exception.message}"
Process.kill('KILL', pid)
Process.wait
false
end
end
def delete_remote_branches
remote_name = ARGV.shift
branches = ARGV.map { |branch_name| ":#{branch_name}" }
$logger.info "Pushing deleted branches from #{full_path} to remote #{remote_name}: #{ARGV}"
cmd = %W(git --git-dir=#{full_path} push -- #{remote_name}).concat(branches)
pid = Process.spawn(*cmd)
begin
Process.wait(pid)
$?.exitstatus.zero?
rescue => exception
$logger.error "Pushing deleted branches to remote #{remote_name} failed due to: #{exception.message}"
Process.kill('KILL', pid)
Process.wait
false
end
end
def create_branch
branch_name = ARGV.shift
ref = ARGV.shift || "HEAD"
......
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