Class: Git::TagList

Inherits:
Object
  • Object
show all
Defined in:
lib/tag_changelog/git/tag_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(include_head = true) ⇒ TagList

Instantiates the tag list.

Parameters:

  • include_head (bool) (defaults to: true)

    Indicates whether or not to include the most recent changes.



32
33
34
35
# File 'lib/tag_changelog/git/tag_list.rb', line 32

def initialize(include_head = true)
  @include_head = include_head
  @list = build_list
end

Instance Attribute Details

#listObject (readonly)

Returns an array of tag names surrounded by HEAD at the top and the sha1 of the first commit at the bottom.



25
26
27
# File 'lib/tag_changelog/git/tag_list.rb', line 25

def list
  @list
end

Instance Method Details

#latest_tagString

Returns the most recent tag in the git repository, or the sha1 of the initial commit if there is no tag.

Returns:

  • (String)


42
43
44
45
46
# File 'lib/tag_changelog/git/tag_list.rb', line 42

def latest_tag
  # Index 0 is HEAD
  # Index 1 is most recent tag or first commit
  @list[1]
end