class Release::Notes::Git

Constants

DEFAULT_TAG

Public Class Methods

first_commit() click to toggle source

Returns the git hash of the first commit.

@return [String] the first commit hash.

# File lib/release/notes/git.rb, line 32
def first_commit
  "git rev-list --max-parents=0 #{DEFAULT_TAG}"
end
last_tag() click to toggle source

Returns the latest git tag.

@return [String] the most recent tag.

# File lib/release/notes/git.rb, line 41
def last_tag
  "git describe --abbrev=0 --tags"
end
log(**opts) click to toggle source

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

@param **opts

@return [String] git log entries between tag_from and tag_to that include the word(s) in label, taking into account the invert grep and log_format flags specified.

# 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
read_all_tags() click to toggle source

Returns an array of all tags in the git log

@return [Array] all git tags

# 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) click to toggle source

Returns the date and time of the latest tag.

@param [String] a git tag

@return [String] the most recent tag date.

# File lib/release/notes/git.rb, line 52
def tag_date(tag)
  "git log -1 --format=%ai #{tag}"
end

Private Class Methods

log_format() click to toggle source

Returns a string representing the git log format flag

@return [String] git log format flag

# File lib/release/notes/git.rb, line 72
def log_format
  "- %s"
end