Class: Milestoner::Tagger
- Inherits:
-
Object
- Object
- Milestoner::Tagger
- Includes:
- Aids::Git
- Defined in:
- lib/milestoner/tagger.rb
Overview
Handles the tagging of a project repository.
Instance Attribute Summary collapse
-
#commit_prefixes ⇒ Object
readonly
Returns the value of attribute commit_prefixes.
-
#version_number ⇒ Object
readonly
Returns the value of attribute version_number.
Class Method Summary collapse
Instance Method Summary collapse
- #commit_list ⇒ Object
- #commit_prefix_regex ⇒ Object
- #commits ⇒ Object
- #create(version = version_number, sign: false) ⇒ Object
- #destroy ⇒ Object
- #duplicate? ⇒ Boolean
-
#initialize(version = nil, commit_prefixes: []) ⇒ Tagger
constructor
A new instance of Tagger.
- #tagged? ⇒ Boolean
- #version_label ⇒ Object
- #version_message ⇒ Object
Methods included from Aids::Git
Constructor Details
#initialize(version = nil, commit_prefixes: []) ⇒ Tagger
Returns a new instance of Tagger.
12 13 14 15 |
# File 'lib/milestoner/tagger.rb', line 12 def initialize version = nil, commit_prefixes: [] @version_number = version @commit_prefixes = commit_prefixes end |
Instance Attribute Details
#commit_prefixes ⇒ Object (readonly)
Returns the value of attribute commit_prefixes.
6 7 8 |
# File 'lib/milestoner/tagger.rb', line 6 def commit_prefixes @commit_prefixes end |
#version_number ⇒ Object (readonly)
Returns the value of attribute version_number.
6 7 8 |
# File 'lib/milestoner/tagger.rb', line 6 def version_number @version_number end |
Class Method Details
.version_regex ⇒ Object
8 9 10 |
# File 'lib/milestoner/tagger.rb', line 8 def self.version_regex /\A\d{1}\.\d{1}\.\d{1}\z/ end |
Instance Method Details
#commit_list ⇒ Object
49 50 51 |
# File 'lib/milestoner/tagger.rb', line 49 def commit_list commits.map { |commit| "- #{commit}" } end |
#commit_prefix_regex ⇒ Object
25 26 27 28 |
# File 'lib/milestoner/tagger.rb', line 25 def commit_prefix_regex return // if commit_prefixes.empty? Regexp.union commit_prefixes end |
#commits ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/milestoner/tagger.rb', line 41 def commits fail(Errors::Git) unless git_supported? groups = build_commit_prefix_groups group_by_commit_prefix! groups sort_by_commit_prefix! groups groups.values.flatten.uniq end |
#create(version = version_number, sign: false) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/milestoner/tagger.rb', line 53 def create version = version_number, sign: false fail(Errors::Git) unless git_supported? @version_number = validate_version version fail(Errors::DuplicateTag, "Duplicate tag exists: #{version_label}.") if duplicate? create_tag sign: sign end |
#destroy ⇒ Object
60 61 62 63 |
# File 'lib/milestoner/tagger.rb', line 60 def destroy fail(Errors::Git) unless git_supported? `git tag --delete #{version_label}` end |
#duplicate? ⇒ Boolean
36 37 38 39 |
# File 'lib/milestoner/tagger.rb', line 36 def duplicate? fail(Errors::Git) unless git_supported? system "git rev-parse #{version_label} > /dev/null 2>&1" end |
#tagged? ⇒ Boolean
30 31 32 33 34 |
# File 'lib/milestoner/tagger.rb', line 30 def tagged? fail(Errors::Git) unless git_supported? response = `git tag` !(response.nil? || response.empty?) end |
#version_label ⇒ Object
17 18 19 |
# File 'lib/milestoner/tagger.rb', line 17 def version_label "v#{version_number}" end |
#version_message ⇒ Object
21 22 23 |
# File 'lib/milestoner/tagger.rb', line 21 def "Version #{version_number}." end |