summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-21 20:31:23 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-21 20:31:23 +0000
commit91e722550b40bbd8214e54a01b2183b27b95bde1 (patch)
tree8d4b2c5fc6590a75438d8240ad7b443d80944db8
parent9f482f8d24c8555ca4fbfd87efb1d155ed581509 (diff)
parent42caddb2f60709e2e135f4e00f57277016a36898 (diff)
downloadgitlab-shell-91e722550b40bbd8214e54a01b2183b27b95bde1.tar.gz
Merge branch 'gl_ee_issue_116' into 'master' v2.6.13
Add new required commands to update remote mirrors Closes gitlab-org/gitlab-ee#116 See merge request !43
-rw-r--r--CHANGELOG4
-rw-r--r--VERSION2
-rw-r--r--lib/gitlab_projects.rb43
3 files changed, 48 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f2b809e..b339938 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+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
diff --git a/VERSION b/VERSION
index c959dfb..6ac04ca 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.6.12
+2.6.13
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index b3d6883..11a5a16 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -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"