Module: Prick::Git::Tag
- Defined in:
- lib/prick/local/git.rb
Class Method Summary collapse
-
.create(tag, id: nil) ⇒ Object
Create tag.
-
.current(id = nil) ⇒ Object
Return the most recent tag before the given commit (defaults to the last commit).
-
.describe_tag(id = nil) ⇒ Object
Return a [tag, number-of-commits, commit-id] tuple of the most recent tag.
-
.drop(tag) ⇒ Object
Drop a tag.
-
.exist?(tag) ⇒ Boolean
True if tag exists.
-
.id(tag) ⇒ Object
The associated commit ID of a tag.
-
.list ⇒ Object
Return list of all tags.
Class Method Details
.create(tag, id: nil) ⇒ Object
Create tag
80 81 82 |
# File 'lib/prick/local/git.rb', line 80 def self.create(tag, id: nil) Command.command "git tag '#{tag}' #{id}" end |
.current(id = nil) ⇒ Object
Return the most recent tag before the given commit (defaults to the last commit)
96 97 98 |
# File 'lib/prick/local/git.rb', line 96 def self.current(id = nil) describe_tag(id)&.first end |
.describe_tag(id = nil) ⇒ Object
Return a [tag, number-of-commits, commit-id] tuple of the most recent tag. Return nil if no tag was found
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/prick/local/git.rb', line 103 def self.describe_tag(id = nil) stdout, stderr = Command.command("git describe --tags #{id}", stderr: true, fail: false) if Command.status != 0 return nil if stderr.first =~ /No names found/ raise Command.exception end if stdout.first =~ /^(.*)-(\d+)-.([0-9a-f]{7})$/ [$1, $2, $3] else [stdout.first, 0, nil] end end |
.drop(tag) ⇒ Object
Drop a tag
85 86 87 |
# File 'lib/prick/local/git.rb', line 85 def self.drop(tag) Command.command "git tag -d '#{tag}'" end |
.exist?(tag) ⇒ Boolean
True if tag exists
75 76 77 |
# File 'lib/prick/local/git.rb', line 75 def self.exist?(tag) tag && Command.command?("git describe --tags #{tag}") end |