release-notes 3.1.0 → 4.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ffa78423d6770331d46c798c4f671984bca8fd896f4ca3238b304163c323b93
4
- data.tar.gz: d64dcf45b0ce332cf57f04796f20a9d133d0f1330733fef796942033d87358c0
3
+ metadata.gz: 49daa419cb2bdfedfabbc46ebeca75fc652d578e7f998578b0d23ea56774f1fe
4
+ data.tar.gz: 89d93e9ff6270daccf930ae5726b4f6e4cfee434d86ccac17798faf99d69d8fe
5
5
  SHA512:
6
- metadata.gz: 5b97056a68f3aacb0cac39b4a38889f90faf97eb55682487db95ab40873d2351def8e793855d17448627c9e7a1fb5d9af0778b9b8828e2b4a0bd35dce2edfe63
7
- data.tar.gz: bfe153fcfc21253aaa4ce136099ddadc2d7e9f44462a24d99c36d74ce243a2bd921410e532fb4f2179b2e12d7b7d44700f97b16cccf4d15eb69c94cc78c1346a
6
+ metadata.gz: f207807fbf4170880c6d2a098a0153345f1e99f5a889fd76ea045e0e30684215be09aceeaeced121e9e3054a293b9b7b0672d257d9601944957ee5e504d0fd9b
7
+ data.tar.gz: 6b9f2670203e27019a0df4459b041aab6d3eaaa4db501a8d6713a1e74de598fe3d7858919b9146a5615a0efb9925463af662f14bde1f0437a055649da60d3042
@@ -5,7 +5,6 @@ Put a brief summary here
5
5
  ## Environment
6
6
 
7
7
  - Ruby **[version]**
8
- - Rails **[version]**
9
8
  - release-notes **[version]**
10
9
 
11
10
  ## Current behavior
@@ -9,12 +9,5 @@ Fixes # (issue)
9
9
  ## Checklist
10
10
 
11
11
  - [ ] My code follows the style guidelines of this project
12
- - [ ] I have rebased the branch with the latest code from master
13
- - [ ] I have performed a self-review of my own code
14
- - [ ] I have commented my code, particularly in hard-to-understand areas, and at the top of new interactors
15
12
  - [ ] I have added tests that prove my fix is effective or that my feature works
16
13
  - [ ] The build is passing
17
-
18
- ## Screenshots (if applicable)
19
-
20
- ## Dependencies introduced
@@ -1,5 +1,31 @@
1
1
  # Release Notes
2
2
 
3
+ ## v4.0.0.pre
4
+
5
+ **Implemented enhancements:**
6
+
7
+ - Update README remove git workflow recomendations for now
8
+ - Add in new Release::Notes::Cmd
9
+ - Add in predicate methods for Configuration
10
+
11
+ **Fixed bugs:**
12
+
13
+ - Fix cops
14
+ - Remove backslash for linked labels
15
+ - Remove rake task. Just support binstub usage
16
+ - Fix up github templates
17
+
18
+ **Miscellaneous:**
19
+
20
+ - Another README update
21
+ - Update README and template in generator
22
+
23
+ ## v3.1.0
24
+
25
+ **Implemented enhancements:**
26
+
27
+ - Add configurable option for format when grabbing git tags
28
+
3
29
  ## v3.0.0
4
30
 
5
31
  **Implemented enhancements:**
data/README.md CHANGED
@@ -63,38 +63,144 @@ $ bundle exec rake release:notes:install
63
63
  Override any of these defaults in `config/initializers/release_notes.rb`:
64
64
 
65
65
  ```ruby
66
+ # frozen_string_literal: true
67
+
66
68
  Release::Notes.configure do |config|
67
- config.output_file = './RELEASE_NOTES.md'
68
- config.temp_file = './release-notes.tmp.md'
69
+ # The absolute path of your generated log.
70
+ # Defaults to `./RELEASE_NOTES.md`.
71
+ # @return [String]
72
+ config.output_file = "./RELEASE_NOTES.md"
73
+
74
+ # The absolute path of the temporary generated log.
75
+ # Defaults to `./release-notes.tmp.md`.
76
+ # @return [String]
77
+ config.temp_file = "./release-notes.tmp.md"
78
+
79
+ # Determines whether to print commits with more than one parent.
80
+ # Defaults to `false`. For more, see
81
+ # [Git Log Docs](https://git-scm.com/docs/git-log)
82
+ # @return [Boolean]
69
83
  config.include_merges = false
84
+
85
+ # Match the regular expression limiting patterns without regard to letter case
86
+ # when printing your git log.
87
+ # Defaults to `true`. For more, see
88
+ # [Git Log Docs](https://git-scm.com/docs/git-log)
89
+ # @return [Boolean]
70
90
  config.ignore_case = true
91
+
92
+ # Consider the limiting patterns to be extended regular expressions patterns
93
+ # when printing your git log.
94
+ # Defaults to `true`. For more, see
95
+ # [Git Log Docs](https://git-scm.com/docs/git-log)
96
+ # @return [Boolean]
71
97
  config.extended_regex = true
98
+
99
+ # Controls the header used in your generated log for all tags.
100
+ # "tag" and "date" are the two valid options
101
+ # Defaults to `tag`.
102
+ # @return [String]
72
103
  config.header_title = "tag"
104
+
105
+ # Allows you to specify what information you want to print from your git log
106
+ # Defaults to `%s` for subject. For more, see
107
+ # [Git Log Docs](https://git-scm.com/docs/git-log)
108
+ # @return [String]
73
109
  config.bug_labels = %w(Fix Update)
110
+
111
+ # Controls the labels grepped for in your commit subjects that will
112
+ # be add under you feature title
113
+ # Defaults to `%w(Add Create)`.
114
+ # @return [Array]
74
115
  config.feature_labels = %w(Add Create)
116
+
117
+ # Controls the labels grepped for in your commit subjects that will
118
+ # be add under you miscellaneous title
119
+ # Defaults to `%w(Refactor)`.
120
+ # @return [Array]
75
121
  config.misc_labels = %w(Refactor)
76
- config.bug_title = '**Fixed bugs:**'
77
- config.feature_title = '**Implemented enhancements:**'
78
- config.misc_title = '**Miscellaneous:**'
79
- config.log_all_title = '**Other:**'
122
+
123
+ # Controls the title used in your generated log for all bugs listed
124
+ # Defaults to `**Fixed bugs:**`.
125
+ # @return [String]
126
+ config.bug_title = "**Fixed bugs:**"
127
+
128
+ # Controls the title used in your generated log for all features listed
129
+ # Defaults to `**Implemented enhancements:**`.
130
+ # @return [String]
131
+ config.feature_title = "**Implemented enhancements:**"
132
+
133
+ # Controls the title used in your generated log for all misc commits listed
134
+ # Defaults to `**Miscellaneous:**`.
135
+ # @return [String]
136
+ config.misc_title = "**Miscellaneous:**"
137
+
138
+ # Controls the title used in your generated log for all commits listed
139
+ # Defaults to `**Other:**`.
140
+ # @return [String]
141
+ config.log_all_title = "**Other:**"
142
+
143
+ # Controls whether all logs that do not match the other labels are listed
144
+ # Defaults to `false`
145
+ # @return [Boolean]
80
146
  config.log_all = false
147
+
148
+ # The labels grepped for in your commit subject that you want to linkify.
149
+ # The index within the array must match the index for the site
150
+ # in `:link_to_humanize` and `:link_to_sites`.
151
+ # Defaults to `[]`.
152
+ # @return [Array]
81
153
  config.link_to_labels = %w()
154
+
155
+ # The humanized output that you'd like to represent the associated `:link_to_label`
156
+ # The index within the array must match the index for the site
157
+ # in `:link_to_label` and `:link_to_sites`.
158
+ # Defaults to `[]`.
159
+ # @return [Array]
82
160
  config.link_to_humanize = %w()
161
+
162
+ # The url for the site that you'd like to represent the associated `:link_to_label`
163
+ # The index within the array must match the index for the site
164
+ # in `:link_to_label` and `:link_to_humanize`.
165
+ # Defaults to `[]`.
166
+ # @return [Array]
83
167
  config.link_to_sites = %w()
84
- config.timezone = 'America/New_York'
168
+
169
+ # Sets the timezone that should be used for setting the date.
170
+ # Defaults to `America/New_York`. For more, see
171
+ # [ActiveSupport Time Zones](http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html)
172
+ # @return [String]
173
+ config.timezone = "America/New_York"
174
+
175
+ # Controls whether your commit subject labels should be removed from the final
176
+ # ouput of your message on the generated log.
177
+ # Defaults to `false`.
178
+ # @return [Boolean]
85
179
  config.prettify_messages = false
86
- config.force_rewrite = false
180
+
181
+ # If a commit message contains words that match more than
182
+ # one group of labels as defined in your configuration, the output
183
+ # will only contain the commit once.
184
+ # Defaults to `true`.
185
+ # @return [Boolean]
87
186
  config.single_label = true
187
+
188
+ # Controls what will be passed to the format flag in `git for-each-ref`
189
+ # Defaults to `tag`.
190
+ # @return [String]
191
+ config.for_each_ref_format = "tag"
192
+
193
+ # Determines whether to use the last two tags to
194
+ # find commits for the output or if this gem should just
195
+ # find all commits after previous tag
196
+ # Defaults to `true`.
197
+ # @return [Boolean]
198
+ config.update_release_notes_before_tag = true
88
199
  end
89
200
  ```
90
201
 
91
- For more information about each individual setting checkout Release::Notes's
92
- [config docs](https://www.rubydoc.info/gems/release-notes).
93
-
94
202
  ## Usage
95
203
 
96
- ### TL;DR
97
-
98
204
  Install the binstub
99
205
 
100
206
  ```sh
@@ -104,62 +210,19 @@ $ bundle binstubs release-notes
104
210
  and run
105
211
 
106
212
  ```sh
107
- $ bin/release-notes
213
+ # make sure to pass your tag if updating before you've pushed the latest tag
214
+ $ bin/release-notes -t v0.2.0
215
+ # OR if running for the first time on a project that might have commits after the latest tag
216
+ $ bin/release-notes --ignore-head
217
+ # OR if using an output file that already exists in a project but would like to rerun all git tags
218
+ $ bin/release-notes --force-rewrite
108
219
  ```
109
220
 
110
- OR, just use the rake task
111
-
112
- ```sh
113
- $ bundle exec rake update_release_notes:run
114
- ```
115
-
116
- ### Git Worklow
117
-
118
- Release::Notes works best with a rebase workflow and requires tagging. General rebase benefits include:
119
-
120
- - One clear commit per feature, bug or miscellaneous addition to the codebase
121
- - Commits in logical time manner
122
-
123
- By default configuration, Release::Notes ignores merges. Along with rebasing, by deafult,
124
- Release::Notes relies mainly on the subject of a commit. Therefore, it's important to craft concise and
125
- meaningful commit subjects with longer bodies as needed for larger feature additions or bug fixes.
126
-
127
- For more information about a rebase workflow or crafting solid commit messages
128
- check out the following links
129
-
130
- - [Commit Messages](http://chris.beams.io/posts/git-commit/)
131
- - [Git Rebase Workflow](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
132
-
133
- ### Deploying with Capistrano
134
-
135
- A sample capistrano rake task might look like:
136
-
137
- ```ruby
138
- # config/deploy/production.rb
139
- namespace :deploy do
140
- before :starting, :update_release_notes
141
-
142
- task :update_release_notes do
143
- # use the binstub
144
- sh 'bin/release-notes"'
145
-
146
- # Then check in your release notes with a commit
147
- sh "git commit -am 'Release to production #{Time.zone.now}'"
148
- sh "git push origin master"
149
- end
150
- end
151
- ```
152
-
153
- Useful information can be found here regarding the
154
- [capistrano flow](http://capistranorb.com/documentation/getting-started/flow/).
155
-
156
- **From there, make sure you tag your releases**
157
-
158
- ## Note
221
+ ## Important Notes
159
222
 
160
223
  - Your project must tag releases(release-notes uses the tag date to output the changes)
161
224
  (PR's to make this more flexible are welcome)
162
- - Linking is opinionated and will link to a URI structure of `#{site-url}/#{issue_number}`. It
225
+ - Linking is opinionated and will link to a URI structure of `#{site-url}#{issue_number}`. It
163
226
  will ouput something like: `[HONEYBADGER #33150353](https://app.honeybadger.io/projects/9999/faults/33150353)`.
164
227
  This also means that your link_to_labels have to be something like `['HB #']` (PR's to make this more flexible are welcome)
165
228
 
@@ -48,10 +48,12 @@ FileUtils.chdir APP_ROOT do
48
48
  end
49
49
  FILE
50
50
 
51
-
52
51
  puts "== Updating version to #{current_version.join('.')} =="
53
52
  File.write("lib/release/notes/version.rb", contents)
54
53
 
54
+ puts "== Release Notes =="
55
+ system! "exe/release-notes generate -t #{current_version.join('.')}"
56
+
55
57
  puts "== Adding Changed Files =="
56
58
  system! "git add ."
57
59
 
@@ -60,16 +62,4 @@ FileUtils.chdir APP_ROOT do
60
62
 
61
63
  puts "== Tagging release =="
62
64
  system! "bundle exec rake release"
63
-
64
- puts "== Release Notes =="
65
- system! "exe/release-notes"
66
-
67
- puts "== Adding updated CHANGELOG =="
68
- system! "git add CHANGELOG.md"
69
-
70
- puts "== Committing updated files =="
71
- system! "git commit -m 'Modify CHANGELOG.md'"
72
-
73
- puts "== Pushing updated files =="
74
- system! "git push origin master"
75
- end
65
+ end
@@ -12,9 +12,7 @@ file = File.exist?(rails_config_file) ? rails_config_file : config_file
12
12
 
13
13
  begin
14
14
  require file
15
- warn "=> Generating release notes..."
16
- Release::Notes.generate
17
- warn "=> Done!"
15
+ Release::Notes::Cmd.start(ARGV)
18
16
  rescue LoadError
19
17
  warn "=> Missing release_notes.rb configuration file"
20
18
  rescue SignalException => e
@@ -113,15 +113,22 @@ Release::Notes.configure do |config|
113
113
  # @return [Boolean]
114
114
  # config.prettify_messages = false
115
115
 
116
- # Controls whether to rewrite the output file or append to it.
117
- # Defaults to `false`.
118
- # @return [Boolean]
119
- # config.force_rewrite = false
120
-
121
116
  # If a commit message contains words that match more than
122
117
  # one group of labels as defined in your configuration, the output
123
118
  # will only contain the commit once.
124
119
  # Defaults to `true`.
125
120
  # @return [Boolean]
126
- # attr_accessor :single_label
121
+ # config.single_label = true
122
+
123
+ # Controls what will be passed to the format flag in `git for-each-ref`
124
+ # Defaults to `tag`.
125
+ # @return [String]
126
+ # config.for_each_ref_format = "tag"
127
+
128
+ # Determines whether to use the last two tags to
129
+ # find commits for the output or if this gem should just
130
+ # find all commits after previous tag
131
+ # Defaults to `true`.
132
+ # @return [Boolean]
133
+ # config.update_release_notes_before_tag = true
127
134
  end
@@ -3,6 +3,10 @@
3
3
  require "active_support"
4
4
  require "active_support/core_ext/time"
5
5
 
6
+ require "thor"
7
+ require "release/notes/cmd"
8
+
9
+ require "release/notes/errors"
6
10
  require "release/notes/configurable"
7
11
  require "release/notes/date_formatter"
8
12
  require "release/notes/link"
@@ -26,19 +30,9 @@ module Release
26
30
  NEWLINE = "\n"
27
31
 
28
32
  class << self
29
- def generate
30
- log.perform
31
- end
32
-
33
33
  def root
34
34
  File.expand_path("..", __dir__)
35
35
  end
36
-
37
- private
38
-
39
- def log
40
- Log.new
41
- end
42
36
  end
43
37
  end
44
38
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Release
4
+ module Notes
5
+ class Cmd < Thor
6
+ desc "generate", "Generate release notes"
7
+ option :tag, type: :string,
8
+ aliases: "-t",
9
+ desc: "The latest tag to use on the file title if the tag is not yet pushed"
10
+ option :'force-rewrite', type: :boolean,
11
+ default: false,
12
+ aliases: "-r",
13
+ desc: "Force release-notes to look at all previous "\
14
+ "tags and rewrite the output file"
15
+ option :'ignore-head', type: :boolean,
16
+ default: false,
17
+ aliases: "-i",
18
+ desc: "If updating your changelog and you don't want the latest commits "\
19
+ "from the last tag to HEAD in a single "\
20
+ "instance of running, set to true"
21
+ def generate
22
+ warn "=> Generating release notes..."
23
+ Log.new(options).perform
24
+ warn "=> Done!"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -3,14 +3,35 @@
3
3
  module Release
4
4
  module Notes
5
5
  module Configurable
6
- delegate :timezone, :grep_insensitive?, :regex_type,
7
- :include_merges?, :link_to_labels, :link_to_sites, :link_to_humanize,
8
- :log_all, :header_title, :header_title_type, :features,
9
- :bugs, :misc, :feature_title,
10
- :bug_title, :misc_title, :log_all_title, :single_label,
11
- :output_file, :temp_file, :link_commits?, :all_labels,
12
- :prettify_messages?, :release_notes_exist?, :for_each_ref_format,
13
- :force_rewrite, prefix: :config, to: :"Release::Notes.configuration"
6
+ delegate :all_labels,
7
+ :bug_title,
8
+ :bugs,
9
+ :feature_title,
10
+ :features,
11
+ :for_each_ref_format,
12
+ :force_rewrite?,
13
+ :grep_insensitive_flag,
14
+ :header_title_type,
15
+ :ignore_head?,
16
+ :link_commits?,
17
+ :link_to_humanize,
18
+ :link_to_labels,
19
+ :link_to_sites,
20
+ :log_all,
21
+ :log_all_title,
22
+ :merge_flag,
23
+ :misc,
24
+ :misc_title,
25
+ :newest_tag,
26
+ :output_file,
27
+ :prettify_messages?,
28
+ :regex_type,
29
+ :release_notes_exist?,
30
+ :single_label,
31
+ :temp_file,
32
+ :timezone,
33
+ :update_release_notes_before_tag?,
34
+ prefix: :config, to: :"Release::Notes.configuration"
14
35
  end
15
36
  end
16
37
  end
@@ -114,11 +114,6 @@ module Release
114
114
  # @return [Boolean]
115
115
  attr_accessor :prettify_messages
116
116
 
117
- # Controls whether to rewrite the output file or append to it.
118
- # Defaults to `false`.
119
- # @return [Boolean]
120
- attr_accessor :force_rewrite
121
-
122
117
  # If a commit message contains words that match more than
123
118
  # one group of labels as defined in your configuration, the output
124
119
  # will only contain the commit once.
@@ -131,29 +126,45 @@ module Release
131
126
  # @return [String]
132
127
  attr_accessor :for_each_ref_format
133
128
 
129
+ # Determines whether to use the last two tags to
130
+ # find commits for the output or if this gem should just
131
+ # find all commits after previous tag
132
+ # Defaults to `true`.
133
+ # @return [Boolean]
134
+ attr_accessor :update_release_notes_before_tag
135
+
134
136
  def initialize
135
- @output_file = "./RELEASE_NOTES.md"
136
- @temp_file = "./release-notes.tmp.md"
137
- @include_merges = false
138
- @ignore_case = true
139
- @extended_regex = true
140
- @header_title = "tag"
141
- @bug_labels = %w(Fix Update)
142
- @feature_labels = %w(Add Create)
143
- @misc_labels = %w(Refactor)
144
- @bug_title = "**Fixed bugs:**"
145
- @feature_title = "**Implemented enhancements:**"
146
- @misc_title = "**Miscellaneous:**"
147
- @log_all_title = "**Other**"
148
- @log_all = false
149
- @link_to_labels = %w()
150
- @link_to_humanize = %w()
151
- @link_to_sites = %w()
152
- @timezone = "America/New_York"
153
- @prettify_messages = false
154
- @force_rewrite = false
155
- @single_label = true
156
- @for_each_ref_format = "tag"
137
+ @output_file = "./RELEASE_NOTES.md"
138
+ @temp_file = "./release-notes.tmp.md"
139
+ @include_merges = false
140
+ @ignore_case = true
141
+ @extended_regex = true
142
+ @header_title = "tag"
143
+ @bug_labels = %w(Fix Update)
144
+ @feature_labels = %w(Add Create)
145
+ @misc_labels = %w(Refactor)
146
+ @bug_title = "**Fixed bugs:**"
147
+ @feature_title = "**Implemented enhancements:**"
148
+ @misc_title = "**Miscellaneous:**"
149
+ @log_all_title = "**Other**"
150
+ @log_all = false
151
+ @link_to_labels = %w()
152
+ @link_to_humanize = %w()
153
+ @link_to_sites = %w()
154
+ @timezone = "America/New_York"
155
+ @prettify_messages = false
156
+ @single_label = true
157
+ @for_each_ref_format = "tag"
158
+ @update_release_notes_before_tag = true
159
+ end
160
+
161
+ instance_methods.each do |meth|
162
+ define_method("#{meth}?") do
163
+ return send(meth) == true if !!send(meth) == send(meth) # rubocop:disable Style/DoubleNegation
164
+
165
+ raise NotBoolean, "Configuration##{meth} does not return a Boolean and
166
+ therefore, has no predicate method."
167
+ end
157
168
  end
158
169
 
159
170
  # @return [String]
@@ -162,18 +173,18 @@ module Release
162
173
  end
163
174
 
164
175
  # @return [String]
165
- def include_merges?
166
- @include_merges ? "" : "--no-merges"
176
+ def merge_flag
177
+ include_merges? ? "" : "--no-merges"
167
178
  end
168
179
 
169
180
  # @return [String]
170
181
  def regex_type
171
- @extended_regex ? "-E" : ""
182
+ extended_regex? ? "-E" : ""
172
183
  end
173
184
 
174
185
  # @return [String]
175
- def grep_insensitive?
176
- @ignore_case ? "-i" : ""
186
+ def grep_insensitive_flag
187
+ ignore_case? ? "-i" : ""
177
188
  end
178
189
 
179
190
  # @return [String]
@@ -207,9 +218,15 @@ module Release
207
218
  link_to_sites.present?
208
219
  end
209
220
 
210
- # @return [Boolean]
211
- def prettify_messages?
212
- @prettify_messages
221
+ def set_instance_var(var, val)
222
+ instance_variable_set("@#{var}", val)
223
+ define_singleton_method(var) do
224
+ instance_variable_get("@#{var}")
225
+ end
226
+
227
+ define_singleton_method("#{var}?") do
228
+ return send(var) == true if !!send(var) == send(var) # rubocop:disable Style/DoubleNegation
229
+ end
213
230
  end
214
231
 
215
232
  private
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Release
4
+ module Notes
5
+ class MissingTag < ArgumentError; end
6
+ class NotBoolean < TypeError; end
7
+ end
8
+ end
@@ -20,8 +20,8 @@ module Release
20
20
  def log(**opts)
21
21
  "git log '#{opts[:tag_from]}'..'#{opts[:tag_to]}'" \
22
22
  " --grep='#{opts[:label]}#{opts[:invert_grep]}'" \
23
- " #{config_regex_type} #{config_grep_insensitive?}" \
24
- " #{config_include_merges?} --format='%h #{log_format}'"
23
+ " #{config_regex_type} #{config_grep_insensitive_flag}" \
24
+ " #{config_merge_flag} --format='%h #{log_format}'"
25
25
  end
26
26
 
27
27
  #
@@ -97,7 +97,7 @@ module Release
97
97
  def replace(line, issue_number, label, index)
98
98
  identifier = "#{label.split(/\s/)[0]} #{issue_number}"
99
99
  humanized = "#{config_link_to_humanize[index]} #{issue_number}"
100
- linked = "[#{humanized}](#{config_link_to_sites[index]}\/#{issue_number.tr('^0-9', '')})"
100
+ linked = "[#{humanized}](#{config_link_to_sites[index]}#{issue_number.tr('^0-9', '')})"
101
101
 
102
102
  line.gsub! identifier, linked
103
103
  line
@@ -5,34 +5,40 @@ module Release
5
5
  class Log
6
6
  include Configurable
7
7
 
8
+ def initialize(opts = {})
9
+ Release::Notes.configure do |c|
10
+ c.set_instance_var(:newest_tag, opts["tag"])
11
+ c.set_instance_var(:force_rewrite, opts["rewrite"])
12
+ c.set_instance_var(:ignore_head, opts["ignore-head"])
13
+ end
14
+ end
15
+
8
16
  #
9
17
  # Release::Notes::Log initializer
10
18
  #
11
19
  # @return none
12
20
  #
13
21
  def perform
14
- if log_from_start?
15
- # Find all tags and get the logs between each tag
16
- # run this the first time if nothing exists
17
- find_all_tags_and_log_all
18
- else
19
- # Find the last tag and group all commits
20
- # under a date header at the time this is run
21
- find_last_tag_and_log
22
- end
22
+ log_from_start? ? find_all_tags_and_log_all : find_last_tag_and_log
23
23
 
24
24
  writer.write_new_file
25
25
  end
26
26
 
27
27
  private
28
28
 
29
+ def commits_since_last_tag
30
+ tag_logger("HEAD", find_previous_tag(0))
31
+ end
32
+
29
33
  #
30
34
  # Find the most recent git tag
31
35
  #
32
36
  # @return [Array] most recent git tag
33
37
  #
34
38
  def find_last_tag_and_log
35
- tag_logger(System.last_tag.strip, previous_tag(0))
39
+ return commits_since_last_tag if read_to_head?
40
+
41
+ tag_logger(System.last_tag.strip, find_previous_tag(1))
36
42
  end
37
43
 
38
44
  #
@@ -42,8 +48,10 @@ module Release
42
48
  #
43
49
  def find_all_tags_and_log_all
44
50
  git_all_tags.each_with_index do |ta, i|
45
- tag_logger(ta, previous_tag(i))
51
+ tag_logger(ta, find_previous_tag(i + 1))
46
52
  end
53
+
54
+ commits_since_last_tag if read_to_head?
47
55
  end
48
56
 
49
57
  #
@@ -52,7 +60,7 @@ module Release
52
60
  # @return [Boolean] append to changelog or start from beginning of git log
53
61
  #
54
62
  def log_from_start?
55
- !config_release_notes_exist? || config_force_rewrite
63
+ !config_release_notes_exist? || config_force_rewrite?
56
64
  end
57
65
 
58
66
  #
@@ -71,8 +79,12 @@ module Release
71
79
  #
72
80
  # @return [String] second most recent git tag
73
81
  #
74
- def previous_tag(index)
75
- git_all_tags[index + 1].yield_self { |t| tag(t) }.strip
82
+ def find_previous_tag(idx)
83
+ git_all_tags[idx].yield_self { |t| tag(t) }.strip
84
+ end
85
+
86
+ def read_to_head?
87
+ config_update_release_notes_before_tag? && !config_ignore_head?
76
88
  end
77
89
 
78
90
  #
@@ -95,7 +107,11 @@ module Release
95
107
  # @return [Object] Release::Notes::Tag object
96
108
  #
97
109
  def tag_logger(tag, previous_tag)
98
- Tag.new(tag: tag, previous_tag: previous_tag, writer: writer).perform
110
+ Tag.new(
111
+ tag: tag,
112
+ previous_tag: previous_tag,
113
+ writer: writer,
114
+ ).perform
99
115
  end
100
116
 
101
117
  #
@@ -33,11 +33,14 @@ module Release
33
33
  store_commits # adds to @_commits
34
34
 
35
35
  if commits_available? # true
36
- writer_digest_header(header_title) # <File:./release-notes.tmp.md (closed)>
36
+ writer_digest_header(header) # <File:./release-notes.tmp.md (closed)>
37
37
  log_commits # hash [0,1,2...], messages for sha
38
38
  end
39
39
 
40
40
  self
41
+ rescue MissingTag => e
42
+ warn "<#{e.class.name.demodulize}>: #{e}"
43
+ raise
41
44
  end
42
45
 
43
46
  private
@@ -67,8 +70,8 @@ module Release
67
70
  #
68
71
  # @return [String] the header to be added to changelog
69
72
  #
70
- def header_title
71
- config_header_title.yield_self { |t| title(t) } # config_header_title = "tag"
73
+ def header
74
+ config_header_title_type.yield_self { |t| title(t) } # config_header_title = "tag"
72
75
  end
73
76
 
74
77
  #
@@ -145,6 +148,15 @@ module Release
145
148
  # @return [String] tag title or formatted tag date to be added to changelog
146
149
  #
147
150
  def title(title)
151
+ return standard_title(title) unless config_update_release_notes_before_tag? && tag == "HEAD"
152
+
153
+ formatted_date unless title == "tag"
154
+ return config_newest_tag if config_newest_tag.present?
155
+
156
+ raise MissingTag, "No tag version was passed as an option when generating release notes"
157
+ end
158
+
159
+ def standard_title(title)
148
160
  title == "tag" ? tag : formatted_date(tag_date)
149
161
  end
150
162
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Release
4
4
  module Notes
5
- VERSION = "3.1.0"
5
+ VERSION = "4.0.0.pre"
6
6
  end
7
7
  end
@@ -56,7 +56,7 @@ module Release
56
56
  # @return none
57
57
  #
58
58
  def write_new_file
59
- copy_over_notes if config_release_notes_exist? && !config_force_rewrite
59
+ copy_over_notes if config_release_notes_exist? && !config_force_rewrite?
60
60
 
61
61
  FileUtils.cp(config_temp_file, config_output_file)
62
62
  FileUtils.rm config_temp_file
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "activesupport", "~> 5.0"
22
+ spec.add_dependency "thor", "~> 0.20"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.12"
24
25
  spec.add_development_dependency "pry", "~> 0.12.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release-notes
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Monroe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-27 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.20'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.20'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -112,10 +126,12 @@ files:
112
126
  - lib/generators/release/notes/install/templates/README
113
127
  - lib/generators/release/notes/install/templates/release_notes.rb
114
128
  - lib/release/notes.rb
129
+ - lib/release/notes/cmd.rb
115
130
  - lib/release/notes/commits.rb
116
131
  - lib/release/notes/configurable.rb
117
132
  - lib/release/notes/configuration.rb
118
133
  - lib/release/notes/date_formatter.rb
134
+ - lib/release/notes/errors.rb
119
135
  - lib/release/notes/git.rb
120
136
  - lib/release/notes/install.rb
121
137
  - lib/release/notes/link.rb
@@ -127,7 +143,6 @@ files:
127
143
  - lib/release/notes/tasks/install.rake
128
144
  - lib/release/notes/version.rb
129
145
  - lib/release/notes/write.rb
130
- - lib/tasks/update_release_notes.rake
131
146
  - release-notes.gemspec
132
147
  homepage: http://github.com/dvmonroe/release-notes
133
148
  licenses:
@@ -144,9 +159,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
159
  version: '0'
145
160
  required_rubygems_version: !ruby/object:Gem::Requirement
146
161
  requirements:
147
- - - ">="
162
+ - - ">"
148
163
  - !ruby/object:Gem::Version
149
- version: '0'
164
+ version: 1.3.1
150
165
  requirements: []
151
166
  rubyforge_project:
152
167
  rubygems_version: 2.7.3
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :update_release_notes do
4
- task :run do
5
- puts "=> Generating release notes..."
6
- Release::Notes.generate
7
- puts "=> Done!"
8
- end
9
- end