As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 96b26d04 authored by Rubén Dávila's avatar Rubén Dávila
Browse files

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.
parent 3d769c75
No related branches found
No related tags found
No related merge requests found
require 'fileutils'
require 'timeout'
require 'open3'
require_relative 'gitlab_config'
require_relative 'gitlab_logger'
Loading
Loading
@@ -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}."
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment