Class: Release::Notes::Git

Inherits:
Object
  • Object
show all
Extended by:
Configurable
Defined in:
lib/release/notes/git.rb

Constant Summary collapse

DEFAULT_TAG =
"HEAD"

Class Method Summary collapse

Class Method Details

.first_commitString

Returns the git hash of the first commit.

Returns:

  • (String)

    the first commit hash.



32
33
34
# File 'lib/release/notes/git.rb', line 32

def first_commit
  "git rev-list --max-parents=0 #{DEFAULT_TAG}"
end

.last_tagString

Returns the latest git tag.

Returns:

  • (String)

    the most recent tag.



41
42
43
# File 'lib/release/notes/git.rb', line 41

def last_tag
  "git describe --abbrev=0 --tags"
end

.log(**opts) ⇒ String

Returns a string matching the following format: "hash - message\n" for all commits falling within the tag_from and tag_to threshold taking account the relevant label, invert grep options, and log format

taking into account the invert grep and log_format flags specified.

Parameters:

  • **opts

Returns:

  • (String)

    git log entries between tag_from and tag_to that include the word(s) in label,



20
21
22
23
24
25
# File 'lib/release/notes/git.rb', line 20

def log(**opts)
  "git log '#{opts[:tag_from]}'..'#{opts[:tag_to]}'" \
    " --grep='#{opts[:label]}#{opts[:invert_grep]}'" \
    " #{config_regex_type} #{config_grep_insensitive_flag}" \
    " #{config_merge_flag} --format='%h #{log_format}'"
end

.log_formatString (private)

Returns a string representing the git log format flag

Returns:

  • (String)

    git log format flag



72
73
74
# File 'lib/release/notes/git.rb', line 72

def log_format
  "- %s"
end

.read_all_tagsArray

Returns an array of all tags in the git log

Returns:

  • (Array)

    all git tags



61
62
63
# File 'lib/release/notes/git.rb', line 61

def read_all_tags
  "git for-each-ref --sort=taggerdate --format='%(#{config_for_each_ref_format})' refs/tags"
end

.tag_date(tag) ⇒ String

Returns the date and time of the latest tag.

Parameters:

  • a (String)

    git tag

Returns:

  • (String)

    the most recent tag date.



52
53
54
# File 'lib/release/notes/git.rb', line 52

def tag_date(tag)
  "git log -1 --format=%ai #{tag}"
end