summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"