Class: Release::Notes::Log
- Inherits:
-
Object
- Object
- Release::Notes::Log
- Includes:
- Configurable
- Defined in:
- lib/release/notes/log.rb
Instance Method Summary collapse
- #commits_since_last_tag ⇒ Object private
-
#find_all_tags_and_log_all ⇒ Array
private
Get all git tags and add to the changelog.
-
#find_last_tag_and_log ⇒ Array
private
Find the most recent git tag.
-
#find_previous_tag(idx) ⇒ String
private
Second to last tag in the git log.
-
#git_all_tags ⇒ Array
private
All tags in the git log.
-
#initialize(opts = {}) ⇒ Log
constructor
A new instance of Log.
-
#log_from_start? ⇒ Boolean
private
Check whether to start from the beginning of the git log.
-
#perform ⇒ Object
Release::Notes::Log initializer.
- #read_to_head? ⇒ Boolean private
-
#tag(git_tag) ⇒ String
private
Get the next git tag or the first tag.
-
#tag_logger(tag, previous_tag) ⇒ Object
private
Create a Release::Notes::Tag object.
-
#writer ⇒ Object
private
Create write object containing the header, title, and log messages for a given tag.
Constructor Details
#initialize(opts = {}) ⇒ Log
Returns a new instance of Log.
8 9 10 11 12 13 14 |
# File 'lib/release/notes/log.rb', line 8 def initialize(opts = {}) Release::Notes.configure do |c| c.set_instance_var(:newest_tag, opts["tag"]) c.set_instance_var(:force_rewrite, opts["rewrite"]) c.set_instance_var(:ignore_head, opts["ignore-head"]) end end |
Instance Method Details
#commits_since_last_tag ⇒ Object (private)
29 30 31 |
# File 'lib/release/notes/log.rb', line 29 def commits_since_last_tag tag_logger("HEAD", find_previous_tag(0)) end |
#find_all_tags_and_log_all ⇒ Array (private)
Get all git tags and add to the changelog
49 50 51 52 53 54 55 |
# File 'lib/release/notes/log.rb', line 49 def .each_with_index do |ta, i| tag_logger(ta, find_previous_tag(i + 1)) end commits_since_last_tag if read_to_head? end |
#find_last_tag_and_log ⇒ Array (private)
Find the most recent git tag
38 39 40 41 42 |
# File 'lib/release/notes/log.rb', line 38 def find_last_tag_and_log return commits_since_last_tag if read_to_head? tag_logger(System.last_tag.strip, find_previous_tag(1)) end |
#find_previous_tag(idx) ⇒ String (private)
Second to last tag in the git log
82 83 84 |
# File 'lib/release/notes/log.rb', line 82 def find_previous_tag(idx) [idx].yield_self { |t| tag(t) }.strip end |
#git_all_tags ⇒ Array (private)
All tags in the git log
71 72 73 |
# File 'lib/release/notes/log.rb', line 71 def ||= System..split(NEWLINE).reverse end |
#log_from_start? ⇒ Boolean (private)
Check whether to start from the beginning of the git log
62 63 64 |
# File 'lib/release/notes/log.rb', line 62 def log_from_start? !config_release_notes_exist? || config_force_rewrite? end |
#perform ⇒ Object
Release::Notes::Log initializer
21 22 23 24 25 |
# File 'lib/release/notes/log.rb', line 21 def perform log_from_start? ? : find_last_tag_and_log writer.write_new_file end |
#read_to_head? ⇒ Boolean (private)
86 87 88 |
# File 'lib/release/notes/log.rb', line 86 def read_to_head? config_update_release_notes_before_tag? && !config_ignore_head? end |
#tag(git_tag) ⇒ String (private)
Get the next git tag or the first tag
97 98 99 |
# File 'lib/release/notes/log.rb', line 97 def tag(git_tag) git_tag.present? ? git_tag : System.first_commit end |
#tag_logger(tag, previous_tag) ⇒ Object (private)
Create a Release::Notes::Tag object
109 110 111 112 113 114 115 |
# File 'lib/release/notes/log.rb', line 109 def tag_logger(tag, previous_tag) Tag.new( tag: tag, previous_tag: previous_tag, writer: writer, ).perform end |
#writer ⇒ Object (private)
Create write object containing the header, title, and log messages for a given tag
122 123 124 |
# File 'lib/release/notes/log.rb', line 122 def writer @writer ||= Write.new end |