retag 0.1.5 → 0.1.6

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: c3eecc35217225b65ef71c75cc8cf5c5ee199291eadcc61b97a58b4899ab4ae3
4
- data.tar.gz: 372810234ee2c03c9829ff86e11ee2b8942831d1fbc18c0ab9e19e34bd5985c3
3
+ metadata.gz: ab9f253e8ff9f3a7bfd637ddaa844cff811d3c75f79fde036bdacd8eb1f58f91
4
+ data.tar.gz: d36f32cb6b21896c28901f18420ef1ccf4207e4cf2683c42407bebd52662f761
5
5
  SHA512:
6
- metadata.gz: 3bd613b85fee317a71a86fa8fff244826e06ca3d02be87e5ac3297ad418c569e895a9ba6e09349e121b749ca7e4f44b00c245b684867f3f8a8925071f8f36a97
7
- data.tar.gz: c12042f6c60820062ab9761ab749ebe904ad843af76f1ef06a9666e9b0c851b436499ca8f3ad787a6961546a022a74c5cd06717eb0012296f9320b906cc42bb9
6
+ metadata.gz: 484c2c98bf6d72545501c1b4b43e139579ee37af5b8f0e1c7e5bf1c28998a8ba4c039fb4a2e7042edbdbf56304420d28b186104863599834c1a6db3ab8c78249
7
+ data.tar.gz: 390312a1b807c7790a80e4bb5e9f68c6644455b267dcbdd965d260af58106030b9b11cbc1477f21ac78f6a230660e09aef1d32313e94a5301f37b32bef60cd5d
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/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.5'
5
+ VERSION = '0.1.6'
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.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri