Class: Release::Notes::Git
- Inherits:
-
Object
- Object
- Release::Notes::Git
- Extended by:
- Configurable
- Defined in:
- lib/release/notes/git.rb
Constant Summary collapse
- DEFAULT_TAG =
"HEAD"
Class Method Summary collapse
-
.first_commit ⇒ String
Returns the git hash of the first commit.
-
.last_tag ⇒ String
Returns the latest git tag.
-
.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.
-
.log_format ⇒ String
private
Returns a string representing the git log format flag.
-
.read_all_tags ⇒ Array
Returns an array of all tags in the git log.
-
.tag_date(tag) ⇒ String
Returns the date and time of the latest tag.
Class Method Details
.first_commit ⇒ String
Returns the git hash of the first commit.
32 33 34 |
# File 'lib/release/notes/git.rb', line 32 def first_commit "git rev-list --max-parents=0 #{DEFAULT_TAG}" end |
.last_tag ⇒ String
Returns the latest git 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.
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_format ⇒ String (private)
Returns a string representing the git log format flag
72 73 74 |
# File 'lib/release/notes/git.rb', line 72 def log_format "- %s" end |
.read_all_tags ⇒ Array
Returns an array of all tags in the git log
61 62 63 |
# File 'lib/release/notes/git.rb', line 61 def "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.
52 53 54 |
# File 'lib/release/notes/git.rb', line 52 def tag_date(tag) "git log -1 --format=%ai #{tag}" end |