Class: Milestoner::Tagger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/milestoner/tagger.rb

Overview

Handles the tagging of a project repository. :reek:TooManyMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commit_prefixes: [], git: Git::Kit.new) ⇒ Tagger

Returns a new instance of Tagger.



19
20
21
22
23
# File 'lib/milestoner/tagger.rb', line 19

def initialize commit_prefixes: [], git: Git::Kit.new
  @commit_prefixes = commit_prefixes
  @git = git
  @shell = Thor::Shell::Color.new
end

Instance Attribute Details

#commit_prefixesObject (readonly)

Returns the value of attribute commit_prefixes.



15
16
17
# File 'lib/milestoner/tagger.rb', line 15

def commit_prefixes
  @commit_prefixes
end

#versionObject (readonly)

Returns the value of attribute version.



15
16
17
# File 'lib/milestoner/tagger.rb', line 15

def version
  @version
end

Instance Method Details

#commit_listObject



37
38
39
# File 'lib/milestoner/tagger.rb', line 37

def commit_list
  commits.map { |commit| "- #{commit}" }
end

#commit_prefix_regexObject



25
26
27
28
# File 'lib/milestoner/tagger.rb', line 25

def commit_prefix_regex
  return Regexp.new("") if commit_prefixes.empty?
  Regexp.union commit_prefixes
end

#commitsObject



30
31
32
33
34
35
# File 'lib/milestoner/tagger.rb', line 30

def commits
  groups = build_commit_prefix_groups
  group_by_commit_prefix groups
  sort_by_commit_prefix groups
  groups.values.flatten.uniq
end

#create(version, sign: false) ⇒ Object

:reek:BooleanParameter



42
43
44
45
46
47
# File 'lib/milestoner/tagger.rb', line 42

def create version, sign: false
  @version = Versionaire::Version version
  fail(Errors::Git, "Unable to tag without commits.") unless git.commits?
  return if existing_tag?
  git_tag sign: sign
end