release-notes 0.1.0 → 1.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 691d3c472f9792ce0e682085a84f2207f6a4fdda
4
- data.tar.gz: bb273e2057859b3a70ffcf692ed6f442152df7d9
2
+ SHA256:
3
+ metadata.gz: cb0b98d5a15dd9a96c2f431aba996b34aafaeeff0b14c402d742b00eadb97fba
4
+ data.tar.gz: 261217599cb38ffc79908c7039af54f3c263bfcf8fa11c1523f08e0d0b754ab0
5
5
  SHA512:
6
- metadata.gz: e056b89f89730bb42537f613e7dcb23363ee4ff25c74aecb54711882935cd2f29912b0a86ef4e3a4af7ea11d5012c55c371033f661b0248ec224b2bd0fb9601b
7
- data.tar.gz: ed86f0d78b8f71c11e8f39766a3e92f403da70c6711e933b375d1c84c061bfffc903c325ea9b494395b817eff227bf5a36933256cf5bab09538c78ebe44a91c1
6
+ metadata.gz: 780b3d9e8f55ffa5384f2886ccdfba0192e98fef078dd10a82fe5df72b3dea21ec99f24d1dc1ceb483bb1325a7dbc1e108b54381293e6b2f566ac33c40d57d7a
7
+ data.tar.gz: 65dd44cd18a4b003b2939f97c2e988081083198ae28f2e4e93296d2e3a583f0753239b12e9a85601d8091fa4663736ea11996f2dd4ffc2a546e2baa672a9b4c7
@@ -0,0 +1,17 @@
1
+ # Issue
2
+
3
+ Put a brief summary here
4
+
5
+ ## Environment
6
+
7
+ - Ruby **[version]**
8
+ - Rails **[version]**
9
+ - release-notes **[version]**
10
+
11
+ ## Current behavior
12
+
13
+ Include code samples, errors, steps to reproduce the error and stacktraces if appropriate.
14
+
15
+ Will be even more helpful if you provide a test case that reproduces the error.
16
+
17
+ ## Expected behavior
@@ -0,0 +1,20 @@
1
+ # Type of PR (feature, enhancement, bug fix, etc.)
2
+
3
+ ## Description
4
+
5
+ Please include a summary of the change and which issue is fixed.
6
+
7
+ Fixes # (issue)
8
+
9
+ ## Programmer Checklist
10
+
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
+ - [ ] I have added tests that prove my fix is effective or that my feature works
16
+ - [ ] The build is passing
17
+
18
+ ## Screenshots (if applicable)
19
+
20
+ ## Dependencies introduced
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  /tmp/
10
10
 
11
11
  RELEASE_NOTES.md
12
- release-notes.tmp.md
12
+ release-notes.tmp.md
13
+ .ruby-version
data/.rubocop.yml ADDED
@@ -0,0 +1,72 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5.3
3
+ Exclude:
4
+ - "bin/*"
5
+ - "./**/*.gemspec"
6
+ - "Gemfile"
7
+ - "Rakefile"
8
+ - "vendor/**/*"
9
+
10
+ Metrics/LineLength:
11
+ Max: 120
12
+
13
+ Metrics/BlockLength:
14
+ Max: 35
15
+ Exclude:
16
+ - "./**/spec/**/*"
17
+
18
+ Style/StringLiterals:
19
+ EnforcedStyle: double_quotes
20
+ Exclude:
21
+ - Gemfile
22
+
23
+ Layout/DotPosition:
24
+ # Multi-line method chaining should be done with trailing dots.
25
+ EnforcedStyle: trailing
26
+
27
+ Style/TrailingCommaInArguments:
28
+ # If `comma`, the cop requires a comma after the last argument, but only for
29
+ # parenthesized method calls where each argument is on its own line.
30
+ EnforcedStyleForMultiline: comma
31
+
32
+ Style/TrailingCommaInArrayLiteral:
33
+ # If `comma`, the cop requires a comma after the last item in an array,
34
+ # but only when each item is on its own line.
35
+ EnforcedStyleForMultiline: comma
36
+
37
+ Style/TrailingCommaInHashLiteral:
38
+ # If `comma`, the cop requires a comma after the last item in a hash,
39
+ # but only when each item is on its own line.
40
+ EnforcedStyleForMultiline: comma
41
+
42
+ Style/MutableConstant:
43
+ # Do not assign mutable objects to constants.
44
+ Enabled: false
45
+
46
+ Style/Documentation:
47
+ # Document classes and non-namespace modules
48
+ Enabled: false
49
+
50
+ Style/ClassAndModuleChildren:
51
+ # Checks style of children classes and modules.
52
+ Enabled: false
53
+
54
+ Style/FrozenStringLiteralComment:
55
+ # Checks existence of the frozen string literal comment
56
+ Enabled: true
57
+
58
+ Style/RescueStandardError:
59
+ # Checks that you are including the error class
60
+ # when you rescue
61
+ Enabled: false
62
+
63
+ Style/PercentLiteralDelimiters:
64
+ # Percent literal delimeters are always parentheses
65
+ PreferredDelimiters:
66
+ { default: (),
67
+ '%i': '()',
68
+ '%I': '()',
69
+ '%r': '()',
70
+ '%w': '()',
71
+ '%W': '()'
72
+ }
data/.travis.yml CHANGED
@@ -1,10 +1,17 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.0
4
+ - 2.4.1
5
+ - 2.4.2
6
+ - 2.4.5
7
+ - 2.5.0
8
+ - 2.5.3
9
+ cache: bundler
5
10
  before_install: gem install bundler -v 1.12.5
6
11
  env:
7
12
  global:
8
13
  secure: ovawk+NnGZGW+hOeC3iPMZ9jKY5FvaxfHLj6XX4Vfe12cq0cdGYirW6pk2uKdJZdE0pC5q4sFv1ZTgcNSTySuNpQ9Gkp4xjcGEVr5JSdmVse8DuxttwkeSPt94DemyMK3f0A3dWN8OJF7/NQbacPeUuXryxmusCqJMlWccVYGeSQQNJ21mFfl2pCf6Z9qls4Q3rzXc4hsVQ5G1B/j9YcMjax0EwXI4cEq/6JadK4OmXrGkCw6M/wvBEqNyhLz+R/gcYiJZqYUETdncRuNiH8N6JKiaCnZUFkGY4bggpOvz29lj3JEQV9jY+3UBeqxuYj3glT7buEuf6//ARedY7IDlupkiDNuSpIKJhzIKAgitc/g+cnUflQV8PiImAEseO0OpoAJ7Bsa688EgyvMgo/kYwjHqZetvlUksQI+XyZ+o7/88LF2Qz4pbuBtdFC4DaKaeqQN5afIHSPtxhYwFA/n+GmY4jymj5ZWod9zZasVdlDgCQzgH5M1W7nEGun8mRW93wf8+3wAx+fXVbB67aDbqJFBJfH6zm/aBCN16kGkHUibRxUyb0F52woBQLUcOIr9Kbujp02D7IK3Z7PFz+DtHfA8aYRXxRDIHxx0tw91UxQzBinsq27kH8EWDmEKMHJeZlMRR4X4ijd6+KFoKUobXFblCeVeO0HCIBxpfTc39w=
14
+ script:
15
+ - bundle exec rubocop
9
16
  after_success:
10
- - bundle exec codeclimate-test-reporter
17
+ - bundle exec codeclimate-test-reporter
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ gemspec
6
6
  group :test do
7
7
  gem 'aruba', '~> 0.14.2'
8
8
  gem 'codeclimate-test-reporter', require: false
9
- gem 'pry-byebug', '~> 3.4.2'
10
9
  gem 'rspec', '~> 3.6.0'
11
10
  gem 'simplecov', require: false
12
11
  end
data/README.md CHANGED
@@ -8,15 +8,16 @@
8
8
  Release notes for the stakeholders.
9
9
 
10
10
  Release::Notes is a small wrapper around your project's git log. The gem is
11
- intended to help increase visability to all team members and stakeholders with
11
+ intended to help increase visability to all team members and/or stakeholders with
12
12
  automated documentation of important changes made to your code base for a given production
13
13
  deployment based on tags and labels in your commit messages.
14
14
 
15
- Release::Notes is different than a changelog. It's meant for situations where other
16
- team members (non-devs) in your organization need to know about key changes
17
- to the production software. If your looking for a comprehnsive changelog that
18
- reflects resolved github issues or logging all merges to your project, I would
19
- suggest you look at something else like
15
+ Release::Notes is different than a changelog. Though it can log all commits, it's
16
+ meant for situations where other team members in your organization need to know about key changes
17
+ to the production software. These key changes are determined by the labeling you set forth
18
+ in the configuration for features, bugs and misc commits.
19
+ If you're looking for a comprehnsive changelog that reflects resolved github issues and uses the
20
+ github api, I'd suggest you look at something else like
20
21
  [github-changelog-generator](https://github.com/skywinder/github-changelog-generator).
21
22
 
22
23
  Not looking for a tested gem or prefer the rawness of a bash script? Checkout the similar
@@ -52,7 +53,6 @@ This Release::Notes generator creates an initializer file to allow further confi
52
53
 
53
54
  If you're not in a rails project you can create the file yourself.
54
55
 
55
-
56
56
  ## Configure
57
57
 
58
58
  Override any of these defaults in `config/initializers/release_notes.rb`:
@@ -65,16 +65,19 @@ Release::Notes.configure do |config|
65
65
  config.ignore_case = true
66
66
  config.log_format = '- %s'
67
67
  config.extended_regex = true
68
- config.bug_labels = %w[Fix Update]
69
- config.feature_labels = %w[Add Create]
70
- config.misc_labels = %w[Refactor]
68
+ config.bug_labels = %w(Fix Update)
69
+ config.feature_labels = %w(Add Create)
70
+ config.misc_labels = %w(Refactor)
71
71
  config.bug_title = '**Fixed bugs:**'
72
72
  config.feature_title = '**Implemented enhancements:**'
73
73
  config.misc_title = '**Miscellaneous:**'
74
- config.link_to_labels = %w[]
75
- config.link_to_humanize = %w[]
76
- config.link_to_sites = %w[]
74
+ config.log_all_title = '**Other:**'
75
+ config.log_all = false
76
+ config.link_to_labels = %w()
77
+ config.link_to_humanize = %w()
78
+ config.link_to_sites = %w()
77
79
  config.timezone = 'America/New_York'
80
+ config.force_rewrite = false
78
81
  end
79
82
  ```
80
83
 
@@ -85,16 +88,24 @@ For more information about each individual setting checkout Release::Notes's
85
88
 
86
89
  ### TL;DR
87
90
 
91
+ #### Rails
92
+
88
93
  ```sh
89
- bundle exec update_release_notes:run
94
+ bin/rails update_release_notes:run
95
+ ```
96
+
97
+ #### Non-Rails
98
+
99
+ ```sh
100
+ bundle exec rake update_release_notes:run
90
101
  ```
91
102
 
92
103
  ### Git Worklow
93
104
 
94
105
  Release::Notes works best with a rebase workflow and requires tagging. General rebase benefits include:
95
106
 
96
- * One clear commit per feature, bug or miscellaneous addition to the codebase
97
- * Commits in logical time manner
107
+ - One clear commit per feature, bug or miscellaneous addition to the codebase
108
+ - Commits in logical time manner
98
109
 
99
110
  By default configuration, Release::Notes ignores merges. Along with rebasing, by deafult,
100
111
  Release::Notes relies mainly on the subject of a commit. Therefore, it's important to craft concise and
@@ -103,18 +114,19 @@ meaningful commit subjects with longer bodies as needed for larger feature addit
103
114
  For more information about a rebase workflow or crafting solid commit messages
104
115
  check out the following links
105
116
 
106
- * [Commit Messages](http://chris.beams.io/posts/git-commit/)
107
- * [Git Rebase Workflow](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
117
+ - [Commit Messages](http://chris.beams.io/posts/git-commit/)
118
+ - [Git Rebase Workflow](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
108
119
 
109
120
  ### Deploying with Capistrano
110
121
 
111
122
  If using Rails, a rake task is included and would be best utilized within your deploy script.
112
123
 
113
- If not on rails, but using rake, you can easily craft your own rake task. At the very least calling
124
+ If not on rails, but using rake, you can easily craft your own rake task. At the very least calling
114
125
 
115
126
  ```ruby
116
127
  Release::Notes::Update.new.run
117
128
  ```
129
+
118
130
  is the only instance that needs to be instantiated and invoked.
119
131
 
120
132
  A sample capistrano production file might look something like this:
@@ -156,11 +168,11 @@ includes this last commit.
156
168
 
157
169
  ## Note
158
170
 
159
- * Your project must tag releases(release-notes uses the tag date to output the changes)
160
- (PR's to make this more flexible are welcome)
161
- * Linking is opinionated and will link to a URI structure of `#{site-url}/#{issue_number}`. It
171
+ - Your project must tag releases(release-notes uses the tag date to output the changes)
172
+ (PR's to make this more flexible are welcome)
173
+ - Linking is opinionated and will link to a URI structure of `#{site-url}/#{issue_number}`. It
162
174
  will ouput something like: `[HONEYBADGER #33150353](https://app.honeybadger.io/projects/9999/faults/33150353)`.
163
- This also means that your link_to_labels have to be something like `['HB #']` (PR's to make this more flexible are welcome)
175
+ This also means that your link_to_labels have to be something like `['HB #']` (PR's to make this more flexible are welcome)
164
176
 
165
177
  ## Development
166
178
 
@@ -172,8 +184,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
172
184
 
173
185
  Bug reports and pull requests are welcome on GitHub at https://github.com/dvmonroe/release-notes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
174
186
 
175
-
176
187
  ## License
177
188
 
178
189
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
179
-
data/bin/console CHANGED
@@ -3,14 +3,6 @@
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'release/notes'
6
- require 'pry-byebug'
7
-
8
- # You can add fixtures and/or initialization code here to make experimenting
9
- # with your gem easier. You can also use a different console, if you like.
10
-
11
- # (If you use this, don't forget to add pry to your Gemfile!)
12
- # require "pry"
13
- # Pry.start
14
6
 
15
7
  require 'irb'
16
8
  IRB.start
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require 'rails/generators/base'
2
+
3
+ require "rails/generators/base"
3
4
 
4
5
  module Release
5
6
  module Notes
6
7
  module Generators
7
8
  class InstallGenerator < Rails::Generators::Base
8
- source_root File.expand_path('../templates', __FILE__)
9
+ source_root File.expand_path("templates", __dir__)
9
10
 
10
11
  def create_release_notes_initializer
11
- copy_file 'release_notes.rb', 'config/initializers/release_notes.rb'
12
+ copy_file "release_notes.rb", "config/initializers/release_notes.rb"
12
13
  end
13
14
 
14
15
  def display_readme
15
- readme 'README'
16
+ readme "README"
16
17
  end
17
18
  end
18
19
  end
@@ -7,14 +7,16 @@ Release::Notes.configure do |config|
7
7
  # config.ignore_case = true
8
8
  # config.log_format = '- %s'
9
9
  # config.extended_regex = true
10
- # config.bug_labels = %w[Fix Update]
11
- # config.feature_labels = %w[Add Create]
12
- # config.misc_labels = %w[Refactor]
10
+ # config.bug_labels = %w(Fix Update)
11
+ # config.feature_labels = %w(Add Create)
12
+ # config.misc_labels = %w(Refactor)
13
13
  # config.bug_title = '**Fixed bugs:**'
14
14
  # config.feature_title = '**Implemented enhancements:**'
15
15
  # config.misc_title = '**Miscellaneous:**'
16
- # config.link_to_labels = %w[]
17
- # config.link_to_humanize = %w[]
18
- # config.link_to_sites = %w[]
16
+ # config.log_all_title = '**Other:**'
17
+ # config.log_all = false
18
+ # config.link_to_labels = %w()
19
+ # config.link_to_humanize = %w()
20
+ # config.link_to_sites = %w()
19
21
  # config.timezone = 'America/New_York'
20
22
  end
data/lib/release/notes.rb CHANGED
@@ -1,22 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support'
4
- require 'active_support/core_ext/time'
3
+ require "active_support"
4
+ require "active_support/core_ext/time"
5
5
 
6
- require 'release/notes/date_format'
7
- require 'release/notes/link'
8
- require 'release/notes/pretty_print'
6
+ require "release/notes/date_format"
7
+ require "release/notes/link"
8
+ require "release/notes/pretty_print"
9
9
 
10
- require 'release/notes/version'
11
- require 'release/notes/configuration'
12
- require 'release/notes/git'
13
- require 'release/notes/system'
14
- require 'release/notes/with_configuration'
10
+ require "release/notes/version"
11
+ require "release/notes/configuration"
12
+ require "release/notes/git"
13
+ require "release/notes/system"
14
+ require "release/notes/with_configuration"
15
15
 
16
- require 'release/notes/write'
17
- require 'release/notes/log'
16
+ require "release/notes/write"
17
+ require "release/notes/log"
18
18
 
19
- require 'release/notes/railtie' if defined?(Rails)
19
+ require "release/notes/railtie" if defined?(Rails)
20
20
 
21
21
  module Release
22
22
  module Notes
@@ -34,7 +34,7 @@ module Release
34
34
  end
35
35
 
36
36
  def self.root
37
- File.expand_path('../..', __FILE__)
37
+ File.expand_path("..", __dir__)
38
38
  end
39
39
  end
40
40
  end
@@ -72,6 +72,16 @@ module Release
72
72
  # @return [String]
73
73
  attr_accessor :misc_title
74
74
 
75
+ # Controls whether all logs that do not match the other labels are listed
76
+ # Defaults to `false`
77
+ # @return [Boolean]
78
+ attr_accessor :log_all
79
+
80
+ # Controls the title used in your generated log for all commits listed
81
+ # Defaults to `**Other:**`.
82
+ # @return [String]
83
+ attr_accessor :log_all_title
84
+
75
85
  # The labels grepped for in your commit subject that you want to linkify.
76
86
  # The index within the array must match the index for the site
77
87
  # in `:link_to_humanize` and `:link_to_sites`.
@@ -105,39 +115,47 @@ module Release
105
115
  # @return [Boolean]
106
116
  attr_accessor :prettify_messages
107
117
 
108
- def initialize
109
- @output_file = './RELEASE_NOTES.md'
110
- @temp_file = './release-notes.tmp.md'
118
+ # Controls whether to rewrite the output file or append to it.
119
+ # Defaults to `false`.
120
+ # @return [Boolean]
121
+ attr_accessor :force_rewrite
122
+
123
+ def initialize # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
124
+ @output_file = "./RELEASE_NOTES.md"
125
+ @temp_file = "./release-notes.tmp.md"
111
126
  @include_merges = false
112
127
  @ignore_case = true
113
128
  @extended_regex = true
114
- @log_format = '- %s'
115
- @bug_labels = %w[Fix Update]
116
- @feature_labels = %w[Add Create]
117
- @misc_labels = %w[Refactor]
118
- @bug_title = '**Fixed bugs:**'
119
- @feature_title = '**Implemented enhancements:**'
120
- @misc_title = '**Miscellaneous:**'
121
- @link_to_labels = %w[]
122
- @link_to_humanize = %w[]
123
- @link_to_sites = %w[]
124
- @timezone = 'America/New_York'
129
+ @log_format = "- %s"
130
+ @bug_labels = %w(Fix Update)
131
+ @feature_labels = %w(Add Create)
132
+ @misc_labels = %w(Refactor)
133
+ @bug_title = "**Fixed bugs:**"
134
+ @feature_title = "**Implemented enhancements:**"
135
+ @misc_title = "**Miscellaneous:**"
136
+ @log_all_title = "**Other**"
137
+ @log_all = false
138
+ @link_to_labels = %w()
139
+ @link_to_humanize = %w()
140
+ @link_to_sites = %w()
141
+ @timezone = "America/New_York"
125
142
  @prettify_messages = true
143
+ @force_rewrite = false
126
144
  end
127
145
 
128
146
  # @return [String]
129
147
  def include_merges?
130
- @include_merges ? '' : '--no-merges'
148
+ @include_merges ? "" : "--no-merges"
131
149
  end
132
150
 
133
151
  # @return [String]
134
152
  def regex_type
135
- @extended_regex ? '-E' : ''
153
+ @extended_regex ? "-E" : ""
136
154
  end
137
155
 
138
156
  # @return [String]
139
157
  def grep_insensitive?
140
- @ignore_case ? '-i' : ''
158
+ @ignore_case ? "-i" : ""
141
159
  end
142
160
 
143
161
  # @return [String]
@@ -176,12 +194,13 @@ module Release
176
194
  @prettify_messages
177
195
  end
178
196
 
197
+ # :nocov:
179
198
  private
180
199
 
181
200
  # @api private
182
201
  # Using over Regexp.union
183
202
  def generate_regex(arr)
184
- arr.join('|').insert(0, '(').insert(-1, ')')
203
+ arr.join("|").insert(0, "(").insert(-1, ")")
185
204
  end
186
205
  end
187
206
 
@@ -206,5 +225,6 @@ module Release
206
225
  def self.configure
207
226
  yield configuration
208
227
  end
228
+ # :nocov:
209
229
  end
210
230
  end
@@ -15,7 +15,7 @@ module Release
15
15
 
16
16
  def date_humanized(date: nil)
17
17
  date = date.present? ? Time.zone.parse(date) : time_now
18
- date.strftime('%B %d, %Y %r %Z')
18
+ date.strftime("%B %d, %Y %r %Z")
19
19
  end
20
20
  end
21
21
  end
@@ -8,17 +8,23 @@ module Release
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  included do
11
- delegate :log_format, :grep_insensitive?, :regex_type, :include_merges?, to: :config
11
+ delegate :all_labels, :log_format, :grep_insensitive?, :regex_type, :include_merges?, to: :config
12
12
 
13
13
  def log(**opts)
14
14
  "git log '#{opts[:tag_from]}'..'#{opts[:tag_to]}' --grep='#{opts[:label]}'" \
15
15
  " #{regex_type} #{grep_insensitive?}" \
16
16
  " #{include_merges?} --format='#{log_format}'"
17
17
  end
18
+
19
+ def invert_log(**opts)
20
+ "git log '#{opts[:tag_from]}'..'#{opts[:tag_to]}' --grep='#{all_labels}'" \
21
+ " #{regex_type} #{grep_insensitive?} --invert-grep" \
22
+ " #{include_merges?} --format='#{log_format}'"
23
+ end
18
24
  end
19
25
 
20
26
  def last_tag
21
- 'git describe --abbrev=0 --tags'
27
+ "git describe --abbrev=0 --tags"
22
28
  end
23
29
 
24
30
  def tag_date(tag)
@@ -26,7 +32,7 @@ module Release
26
32
  end
27
33
 
28
34
  def read_all_tags
29
- 'git tags | sort -u -r'
35
+ "git tags | sort -u -r"
30
36
  end
31
37
  end
32
38
  end
@@ -9,35 +9,49 @@ module Release
9
9
  delegate :link_to_labels, :link_to_sites, :link_to_humanize, to: :config
10
10
 
11
11
  def link_lines(lines:)
12
- new_lines = ''
12
+ @new_lines = ""
13
+ split_lines(lines)
14
+ @new_lines
15
+ end
16
+
17
+ # :nocov:
18
+ private
19
+
20
+ # @api private
21
+ def split_lines(lines)
13
22
  lines.split("\n").each do |line|
14
- unless link_to_labels.any? { |la| line.include? la }
15
- new_lines += "#{line}\n"
23
+ unless link_to_labels { |la| line.include? la }
24
+ @new_lines += "#{line}\n"
16
25
  next
17
26
  end
18
- link_to_labels.each_with_index do |label, i|
19
- next unless line.include? label
20
- words = line.split(/\s/)
21
- words.each do |word|
22
- next unless (word =~ /^#.*/)&.zero?
23
- new_lines += "#{replace(line, word, label, i)}\n"
24
- end
25
- end
27
+ split_words(line)
26
28
  end
27
- new_lines
28
29
  end
29
30
 
30
- private
31
+ # @api private
32
+ def split_words(line)
33
+ link_to_labels.each_with_index do |label, i|
34
+ next unless line.include? label
35
+
36
+ words = line.split(/\s/)
37
+ words.each do |word|
38
+ next unless (word =~ /^#.*/)&.zero?
39
+
40
+ @new_lines += "#{replace(line, word, label, i)}\n"
41
+ end
42
+ end
43
+ end
31
44
 
32
45
  # @api private
33
46
  def replace(line, issue_number, label, index)
34
47
  identifier = "#{label.split(/\s/)[0]} #{issue_number}"
35
48
  humanized = "#{link_to_humanize[index]} #{issue_number}"
36
- linked = "[#{humanized}](#{link_to_sites[index]})"
49
+ linked = "[#{humanized}](#{link_to_sites[index]}\/#{issue_number.tr('^0-9', '')})"
37
50
 
38
51
  line.gsub! identifier, linked
39
52
  line
40
53
  end
54
+ # :nocov:
41
55
  end
42
56
  end
43
57
  end
@@ -9,11 +9,10 @@ module Release
9
9
  attr_reader :config, :writer, :date_formatter
10
10
  attr_reader :all_tags
11
11
 
12
- delegate :all_labels, :features, :bugs, :misc, :feature_title,
13
- :bug_title, :misc_title, :release_notes_exist?, to: :config
14
-
12
+ delegate :force_rewrite, :all_labels, :log_all, :features, :bugs, :misc, :feature_title,
13
+ :bug_title, :misc_title, :log_all_title, :release_notes_exist?, to: :config
15
14
  delegate :date_humanized, :format_tag_date, to: :date_formatter
16
- delegate :digest, to: :writer
15
+ delegate :digest_date, :digest_title, to: :writer
17
16
 
18
17
  def initialize(config)
19
18
  @config = config
@@ -23,7 +22,7 @@ module Release
23
22
  end
24
23
 
25
24
  def perform
26
- if release_notes_exist?
25
+ if release_notes_exist? && !force_rewrite
27
26
  # Find the last tag and group all commits
28
27
  # under a date header at the time this is run
29
28
  find_last_tag_and_log
@@ -35,20 +34,26 @@ module Release
35
34
  writer.write_new_file
36
35
  end
37
36
 
37
+ # :nocov:
38
38
  private
39
39
 
40
- def all_tags
40
+ def all_tags # rubocop:disable Lint/DuplicateMethods
41
41
  @all_tags ||= System.all_tags.split("\n")
42
42
  # return Error.new(msg: :missing_tags) unless all_tags.present?
43
43
  end
44
44
 
45
45
  # @api private
46
46
  def copy_single_tag_of_activity(tag_from:, tag_to: nil)
47
- tag_to ||= 'HEAD'
47
+ tag_to ||= "HEAD"
48
48
  [features, bugs, misc].each_with_index do |regex, i|
49
- log = system_call(tag_from: tag_from, tag_to: tag_to, label: regex)
50
- digest(date: nil, title: titles[i], log_message: log) if log.present?
49
+ log = system_call(tag_from: tag_from, tag_to: tag_to, label: regex, log_all: false)
50
+ digest_title(title: titles[i], log_message: log) if log.present?
51
51
  end
52
+
53
+ return unless log_all
54
+
55
+ log = system_call(tag_from: tag_from, tag_to: tag_to, log_all: true)
56
+ digest_title(title: log_all_title, log_message: log) if log.present?
52
57
  end
53
58
 
54
59
  # @api private
@@ -57,7 +62,7 @@ module Release
57
62
  return false unless system_call(tag_from: last_tag, label: all_labels).present?
58
63
 
59
64
  # output the date right now
60
- digest date: date_humanized
65
+ digest_date date: date_humanized
61
66
  copy_single_tag_of_activity(tag_from: last_tag)
62
67
  end
63
68
 
@@ -78,7 +83,7 @@ module Release
78
83
  next unless previous_tag.present? &&
79
84
  system_call(tag_from: previous_tag, tag_to: ta, label: all_labels).present?
80
85
 
81
- digest date: date_humanized(date: System.tag_date(tag: ta))
86
+ digest_date date: date_humanized(date: System.tag_date(tag: ta))
82
87
  copy_single_tag_of_activity(tag_from: previous_tag, tag_to: ta)
83
88
  end
84
89
  end
@@ -90,10 +95,10 @@ module Release
90
95
  end
91
96
  end
92
97
 
93
- # @api private
94
98
  def titles
95
99
  [feature_title, bug_title, misc_title]
96
100
  end
101
+ # :nocov:
97
102
  end
98
103
  end
99
104
  end
@@ -9,16 +9,18 @@ module Release
9
9
  delegate :all_labels, to: :config
10
10
 
11
11
  def prettify(line:)
12
- line.gsub(labels_regex, '').strip
12
+ line.gsub(labels_regex, "").strip
13
13
  end
14
14
  end
15
15
 
16
+ # :nocov:
16
17
  private
17
18
 
18
19
  # @api private
19
20
  def labels_regex
20
21
  Regexp.new all_labels, Regexp::IGNORECASE
21
22
  end
23
+ # :nocov:
22
24
  end
23
25
  end
24
26
  end
@@ -4,11 +4,11 @@ module Release
4
4
  module Notes
5
5
  class Railtie < Rails::Railtie
6
6
  rake_tasks do
7
- load 'tasks/update_release_notes.rake'
7
+ load "tasks/update_release_notes.rake"
8
8
  end
9
9
 
10
10
  generators do
11
- require 'generators/release/notes/install/install_generator.rb'
11
+ require "generators/release/notes/install/install_generator.rb"
12
12
  end
13
13
  end
14
14
  end
@@ -10,7 +10,11 @@ module Release
10
10
 
11
11
  included do
12
12
  def system_log(**opts)
13
- `#{log(opts)}`
13
+ if opts[:log_all] == true
14
+ `#{invert_log(opts)}`
15
+ else
16
+ `#{log(opts)}`
17
+ end
14
18
  end
15
19
  end
16
20
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Release
4
4
  module Notes
5
- VERSION = '0.1.0'
5
+ VERSION = "1.0.0.pre"
6
6
  end
7
7
  end
@@ -10,7 +10,7 @@ module Release
10
10
  attr_accessor :config
11
11
 
12
12
  delegate :output_file, :temp_file, :link_commits?, :all_labels,
13
- :prettify_messages?, :release_notes_exist?, to: :config
13
+ :prettify_messages?, :release_notes_exist?, :force_rewrite, to: :config
14
14
 
15
15
  def initialize(config)
16
16
  @config = config
@@ -18,35 +18,64 @@ module Release
18
18
  new_temp_file_template
19
19
  end
20
20
 
21
- def digest(date: nil, title: nil, log_message: nil)
22
- File.open(temp_file, 'a') do |fi|
23
- fi << "\n\n## #{date}\n" if date
24
- fi << "\n#{title}\n\n" if title && !date
25
- fi << "#{title}\n\n" if title && date
26
-
27
- break unless log_message
28
- # link messages if needed
29
- msg = link_message log_message
30
- # remove tags if needed
31
- msg = with_config(config: config) { prettify(line: msg) } if prettify_messages?
32
- fi << "#{msg}\n"
33
- end
21
+ # write strings to tempfile
22
+ def digest(str)
23
+ File.open(temp_file, "a") { |fi| fi << str }
24
+ end
25
+
26
+ # formats titles to be added to the new file
27
+ # removes tags from title if configured
28
+ def digest_title(title: nil, log_message: nil)
29
+ @title = title
30
+ @log_message = log_message
31
+
32
+ titles = ""
33
+ titles << title_present
34
+ titles << "#{remove_tags}\n"
35
+ digest(titles)
36
+ end
37
+
38
+ # formats dates to be added to the new file
39
+ def digest_date(date: nil)
40
+ @date = date
41
+ digest(date_present)
34
42
  end
35
43
 
36
44
  # append old file to new temp file
37
45
  # overwrite output file with tmp file
38
46
  def write_new_file
39
- copy_over_notes if release_notes_exist?
47
+ copy_over_notes if release_notes_exist? && !force_rewrite
40
48
 
41
49
  FileUtils.cp(temp_file, output_file)
42
50
  FileUtils.rm temp_file
43
51
  end
44
52
 
53
+ # :nocov:
45
54
  private
46
55
 
56
+ # @api private
57
+ def date_present
58
+ "\n## #{@date}\n"
59
+ end
60
+
61
+ # @api private
62
+ def title_present
63
+ "\n#{@title}\n\n"
64
+ end
65
+
66
+ # @api private
67
+ def remove_tags
68
+ with_config(config: config) { prettify(line: link_messages) } if prettify_messages?
69
+ end
70
+
71
+ # @api private
72
+ def link_messages
73
+ link_message @log_message
74
+ end
75
+
47
76
  # @api private
48
77
  def copy_over_notes
49
- File.open(temp_file, 'a') do |f|
78
+ File.open(temp_file, "a") do |f|
50
79
  f << "\n"
51
80
  IO.readlines(output_file)[2..-1].each { |line| f << line }
52
81
  end
@@ -55,6 +84,7 @@ module Release
55
84
  # @api private
56
85
  def link_message(log_message)
57
86
  return log_message unless link_commits?
87
+
58
88
  with_config(config: config) do
59
89
  link_lines(lines: log_message)
60
90
  end
@@ -62,11 +92,12 @@ module Release
62
92
 
63
93
  # @api private
64
94
  def new_temp_file_template
65
- File.new(temp_file, 'w')
66
- File.open(temp_file, 'a') do |fi|
67
- fi << "# Release Notes\n----------------------"
95
+ File.new(temp_file, "w")
96
+ File.open(temp_file, "a") do |fi|
97
+ fi << "# Release Notes\n"
68
98
  end
69
99
  end
100
+ # :nocov:
70
101
  end
71
102
  end
72
103
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  namespace :update_release_notes do
4
4
  task run: :environment do
5
+ puts "generating release notes..."
5
6
  Release::Notes::Update.new.run
7
+ puts "done!"
6
8
  end
7
9
  end
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'release/notes/version'
3
+ require "release/notes/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "release-notes"
@@ -9,8 +8,8 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Drew Monroe"]
10
9
  spec.email = ["dvmonroe6@gmail.com"]
11
10
 
12
- spec.summary = "Release notes for stakeholders"
13
- spec.description = spec.summary
11
+ spec.summary = "Automated release notes for your project"
12
+ spec.description = "Generate automated release notes for any project"
14
13
  spec.homepage = "http://github.com/dvmonroe/release-notes"
15
14
  spec.license = "MIT"
16
15
 
@@ -19,7 +18,10 @@ Gem::Specification.new do |spec|
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ["lib"]
21
20
 
22
- spec.add_dependency 'activesupport'
23
- spec.add_development_dependency 'bundler', '~> 1.12'
24
- spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_dependency "activesupport", "~> 5.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "pry", "~> 0.12.2"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rubocop", "~> 0.60.0"
25
27
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release-notes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.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: 2017-05-14 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.12.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.12.2
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,16 +66,32 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '10.0'
55
- description: Release notes for stakeholders
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.60.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.60.0
83
+ description: Generate automated release notes for any project
56
84
  email:
57
85
  - dvmonroe6@gmail.com
58
86
  executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
90
+ - ".github/ISSUE_TEMPLATE.md"
91
+ - ".github/PULL_REQUEST_TEMPLATE.md"
62
92
  - ".gitignore"
63
93
  - ".rspec"
64
- - ".ruby-version"
94
+ - ".rubocop.yml"
65
95
  - ".travis.yml"
66
96
  - ".yardopts"
67
97
  - CODE_OF_CONDUCT.md
@@ -103,13 +133,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
133
  version: '0'
104
134
  required_rubygems_version: !ruby/object:Gem::Requirement
105
135
  requirements:
106
- - - ">="
136
+ - - ">"
107
137
  - !ruby/object:Gem::Version
108
- version: '0'
138
+ version: 1.3.1
109
139
  requirements: []
110
140
  rubyforge_project:
111
- rubygems_version: 2.6.10
141
+ rubygems_version: 2.7.6
112
142
  signing_key:
113
143
  specification_version: 4
114
- summary: Release notes for stakeholders
144
+ summary: Automated release notes for your project
115
145
  test_files: []
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.4.0