summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-31 18:15:59 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-31 18:15:59 +0000
commitb8dffd8379b4c2e29243805396bda71c512e004b (patch)
treef6cdcd350898592d7b074c3edf81969279f43c6c
parent3d769c75fe5623c50bdea7fd7b82987dc3d7d74f (diff)
parent29edc61c679047cb02a9a51a94cc6ef68f39b2b4 (diff)
downloadgitlab-shell-b8dffd8379b4c2e29243805396bda71c512e004b.tar.gz
Merge branch 'issue_39' into 'master' v2.7.1
Add new command to list tags from a remote repo. The output of the `git ls-remote` command is written to the STDOUT so the client can read and parse the list of tags. If there is an error it's also written to STDOUT. Closes #39 See merge request !47
-rw-r--r--CHANGELOG3
-rw-r--r--VERSION2
-rw-r--r--lib/gitlab_projects.rb25
3 files changed, 28 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d464bfc..69a330f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v2.7.1
+ - Add new command to list tags from a remote repo
+ - Add the ability to fetch remote repo with or without tags
v2.7.0
- Add support for ssh AuthorizedKeysCommand query by key
diff --git a/VERSION b/VERSION
index 24ba9a3..860487c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.7.0
+2.7.1
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index 0193a18..77d70df 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -1,5 +1,6 @@
require 'fileutils'
require 'timeout'
+require 'open3'
require_relative 'gitlab_config'
require_relative 'gitlab_logger'
@@ -63,6 +64,7 @@ class GitlabProjects
when 'update-head'; update_head
when 'push-branches'; push_branches
when 'delete-remote-branches'; delete_remote_branches
+ when 'list-remote-tags'; list_remote_tags
when 'gc'; gc
else
$logger.warn "Attempt to execute invalid gitlab-projects command #{@command.inspect}."
@@ -73,11 +75,32 @@ class GitlabProjects
protected
+ def list_remote_tags
+ remote_name = ARGV.shift
+
+ tag_list, exit_code, error = nil
+ cmd = %W(git --git-dir=#{full_path} ls-remote --tags #{remote_name})
+
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
+ tag_list = stdout.read
+ error = stderr.read
+ exit_code = wait_thr.value.exitstatus
+ end
+
+ if exit_code.zero?
+ puts tag_list
+ true
+ else
+ puts error
+ false
+ end
+ end
+
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)
+ cmd = %W(git --git-dir=#{full_path} push -- #{remote_name}).concat(ARGV)
pid = Process.spawn(*cmd)
begin