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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/retag +23 -6
- data/lib/retag/repo.rb +16 -2
- data/lib/retag/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08fafd02b0f8303e61cf27f338a7f06cf0c15ddd3c0d3f46d90ef5cd3af70736'
|
4
|
+
data.tar.gz: 1cf4a60243193e23ebceb8e039c1cee3995f1511eb627fbe782a05dbcd9ab508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6bb908c029857da4d61be1c4ff47a13a2addd99966a41206b4326a961c675f5b0a4ec51a865b6a56f3cd1389238c8694d5cbe2a5a5f0ed435c3ff424ef1ce81
|
7
|
+
data.tar.gz: bc4dfbcdabf013a4f9e1c981d272a212712471e5ac4697a0343c47c220e9464e416ed4f0fe386ecb6c50d4a274e13bb23569e5797917e364f4a66e78ba2e2ba6
|
data/Gemfile.lock
CHANGED
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.
|
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
|
-
|
35
|
-
|
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