retag 0.1.4 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab2e731e32312b3a61a674ad910c1193b77130f6b7f72a93ec0675580bd5b078
4
- data.tar.gz: 97835c0e4826a38949abd6de5882652705594eba0c24b501c8cec96a23f44151
3
+ metadata.gz: '08fafd02b0f8303e61cf27f338a7f06cf0c15ddd3c0d3f46d90ef5cd3af70736'
4
+ data.tar.gz: 1cf4a60243193e23ebceb8e039c1cee3995f1511eb627fbe782a05dbcd9ab508
5
5
  SHA512:
6
- metadata.gz: d8bcbd2c1f5d286e9729b93179c6b03905533d2d71a06b07b361a55994a69ad9ccd981c94a37ea925f69caceb390591eee716cd4656a359c9a47e13a911d844c
7
- data.tar.gz: 0352ce3e3aab8140a8e65cde805f5ca7846238a9725178a5c42dada297f90ca3c45bdcdc7a143c3ee34b8ce71204cdaaf7b455b29d8a1175fafc8da6b1cfef56
6
+ metadata.gz: b6bb908c029857da4d61be1c4ff47a13a2addd99966a41206b4326a961c675f5b0a4ec51a865b6a56f3cd1389238c8694d5cbe2a5a5f0ed435c3ff424ef1ce81
7
+ data.tar.gz: bc4dfbcdabf013a4f9e1c981d272a212712471e5ac4697a0343c47c220e9464e416ed4f0fe386ecb6c50d4a274e13bb23569e5797917e364f4a66e78ba2e2ba6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retag (0.1.4)
4
+ retag (0.1.6)
5
5
  activesupport (~> 6.0)
6
6
  colorize
7
7
  gitlab
data/bin/retag CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'yaml'
4
+ require 'erb'
4
5
  require 'thor'
5
6
  require 'colorize'
6
7
  require 'retag'
@@ -31,8 +32,8 @@ class RepoCommand < Thor
31
32
  desc: "Tag message"
32
33
 
33
34
  def tag(project, tag)
34
- $logger.level = :debug if opts['verbose']
35
35
  opts = options.to_h.dup
36
+ $logger.level = :debug if opts['verbose']
36
37
 
37
38
  begin
38
39
  Gitlab.client.delete_tag(project, tag).inspect
@@ -42,6 +43,22 @@ class RepoCommand < Thor
42
43
 
43
44
  puts Gitlab.client.create_tag(project, tag, options['ref'], options['message']).inspect
44
45
  end
46
+
47
+ desc "release <project> <tag>", "Create tag in Gitlab project"
48
+ long_desc <<-LONGDESC
49
+ LONGDESC
50
+
51
+ option :ref, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_REF", 'master'),
52
+ required: true,
53
+ type: :string,
54
+ desc: "Gtilab refspec from which create tag"
55
+
56
+ option :description, default: nil,
57
+ type: :string,
58
+ desc: "description Markdown"
59
+ def release(project, tag)
60
+ Gitlab.client.create_project_release(project, name: tag, tag_name: tag, description: options['description'], ref: options['ref'])
61
+ end
45
62
  end
46
63
 
47
64
  class DockerCommand < Thor
@@ -65,8 +82,8 @@ class DockerCommand < Thor
65
82
  "
66
83
 
67
84
  def tag(*_args)
68
- $logger.level = :debug if opts['verbose']
69
85
  opts = options.to_h.dup
86
+ $logger.level = :debug if opts['verbose']
70
87
 
71
88
  img, tag = opts['image'].split(':')
72
89
  tag ||= 'latest'
@@ -96,14 +113,14 @@ class ReleaseCommand < Thor
96
113
  opts = options.to_h.dup
97
114
  $logger.level = :debug if opts['verbose']
98
115
 
99
- config = YAML.load_file(File.expand_path(opts['config']))
116
+ config = YAML.load(ERB.new(File.read(File.expand_path(opts['config']))).result)
100
117
  config['release'] = opts['name'] || config['release']
101
118
 
102
119
  release = config['release'].to_s
103
- suffix = config['suffix']
104
- branch = config['branch']
120
+ suffix = config['default-suffix']
121
+ branch = config['default-branch']
105
122
 
106
- services = config['services'].map do|(name, cfg)|
123
+ services = config['services'].map do|(name, cfg)|
107
124
  Retag::Service.new(name, cfg, release, suffix: cfg.fetch('suffix', suffix), branch: cfg.fetch('branch', branch)) unless name.start_with?('.')
108
125
  end.compact
109
126
 
data/lib/retag/repo.rb CHANGED
@@ -31,13 +31,27 @@ module Retag
31
31
 
32
32
  def revision
33
33
  @revision ||= begin
34
- rev_name_pair = cmd!("git ls-remote #{repo} #{branch}", capture: true).split("\n").select{|line| line[/\/#{branch}$/] }.first
35
- raise "There is no #{branch} revision at #{repo}" if rev_name_pair.nil?
34
+ # "^{}" means the object could be a tag. https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitrevisions.html#_specifying_revisions
35
+ # Example:
36
+ # git ls-remote git@gir.example.com:repo.git | grep release-latest
37
+ # 174cf2b6685df563e59c5cd0d367996fcf24f0ae refs/tags/release-latest <-- annotated tag itself
38
+ # 47208e276cd277896887417a383e05973278438c refs/tags/release-latest^{} <-- WE NEED: original commit tag is references to
39
+ rev_name_pair = remote_refs(repo, branch+"^{}") # try to find commit tag is references to
40
+ rev_name_pair ||= remote_refs(repo, branch) # try to find simple branch or commit
41
+
42
+ raise "There is no '#{branch}' revision at #{repo}" if rev_name_pair.nil?
43
+
36
44
  rev, _name = rev_name_pair.split
37
45
  rev[0..7]
38
46
  end
39
47
  end
40
48
 
49
+ private
50
+
51
+ def remote_refs repo, branch
52
+ cmd!("git ls-remote #{repo} #{branch}", capture: true).split("\n").select{|line| line.strip.end_with?("/#{branch}") }.first
53
+ end
54
+
41
55
  end
42
56
  end
43
57
 
data/lib/retag/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Retag
4
4
 
5
- VERSION = '0.1.4'
5
+ VERSION = '0.1.8'
6
6
 
7
7
  end
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri