release-notes 1.3.0 → 2.0.0

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: 11a25ad25c53aea05501c671b7d7e6b56be58408733ffda7537f727682bc4997
4
- data.tar.gz: 64cf10fe71b5486a1f8084c1b735cfa539cf709d1f75c98d6dca55bf88181f05
3
+ metadata.gz: 3db50bbc2d93a02a0f3734d38418ed4cfb9ccf7b51cfd0eb33e78ac9c26fa2f4
4
+ data.tar.gz: 886d3f94f4b06ba7bf4d7c9b3bd67802c4ffe48a885e84067489d56b8c804dda
5
5
  SHA512:
6
- metadata.gz: 07046b845aad862743042afda74fc749a22e97904f86c87ca9717b471e6ef2402e5e4145ad5a469405957fabf6cfda7da3362be22ca647be51ce7de7dafcb0cb
7
- data.tar.gz: 56dd24a83704f5a108f2b0730fdf8e7a8155aa57ee0ad1dd20f677571fe3273a15a2b6ca07e57ec06ec9473478a98bd3a96ef3a3a7f97a96c03e3f6ab7deb28b
6
+ metadata.gz: f31ea87a15850deaf208c6dba14eed22e9bc844318e7ac40b4781e1f351d6a71ff6dfa56decdf759b764aeb3edfecff9ac9a932bbd197bb74927fc802f6134f1
7
+ data.tar.gz: 2c7d83dbcba108213ac4d464cdb998a3e88da136d5850969ba98e77686de3b338d9066827757f1424b4dc4fbcb4bdb41577c72445ce1d7f3245481729d4852f3
@@ -0,0 +1,5 @@
1
+ version: "2"
2
+ plugins:
3
+ rubocop:
4
+ enabled: true
5
+ channel: rubocop-0-60
data/.gitignore CHANGED
@@ -8,6 +8,6 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
 
11
- RELEASE_NOTES.md
12
11
  release-notes.tmp.md
13
12
  .ruby-version
13
+ RELEASE_NOTES.md
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.5.3
2
+ TargetRubyVersion: 2.6.0
3
3
  Exclude:
4
4
  - "bin/*"
5
5
  - "./**/*.gemspec"
@@ -13,6 +13,8 @@ Metrics/LineLength:
13
13
 
14
14
  Metrics/MethodLength:
15
15
  Max: 21
16
+ Exclude:
17
+ - "lib/release/notes/configuration.rb"
16
18
 
17
19
  Metrics/BlockLength:
18
20
  Max: 40
@@ -1,9 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
5
4
  - 2.4.5
6
5
  - 2.5.3
6
+ - 2.6.0
7
7
  cache: bundler
8
8
  before_install: gem install bundler -v 1.17.1
9
9
  env:
@@ -0,0 +1,147 @@
1
+ # Release Notes
2
+
3
+ ## v1.3.0
4
+
5
+ **Implemented enhancements:**
6
+
7
+ - Add Configuration#header_title
8
+ - More updates to README
9
+ - Update README to explain how grep works
10
+ - Add logo
11
+ - Remove System#invert_log ;B
12
+
13
+ **Fixed bugs:**
14
+
15
+ - Amend rubocop config & remove inline disables
16
+
17
+ **Miscellaneous:**
18
+
19
+ - Bump release-notes to 1.3.0
20
+
21
+ ## v1.2.1
22
+
23
+ **Fixed bugs:**
24
+
25
+ - Fix cognitive complexity of split_words ;F
26
+
27
+ **Miscellaneous:**
28
+
29
+ - Bump release-notes to 1.2.1
30
+
31
+ ## v1.2.0
32
+
33
+ **Implemented enhancements:**
34
+
35
+ - Output the line if not prettifying (#35)
36
+
37
+ **Fixed bugs:**
38
+
39
+ - Fix log_all option and invert-grep ;B
40
+ - Fix travis - actually run rspec tests ;B
41
+
42
+ **Miscellaneous:**
43
+
44
+ - Bump release-notes to 1.2.0
45
+
46
+ ## v1.1.2
47
+
48
+ **Implemented enhancements:**
49
+
50
+ - Update binstub to support config file in config/ folder
51
+
52
+ **Miscellaneous:**
53
+
54
+ - Bump release-notes to 1.1.2
55
+
56
+ ## v1.1.1
57
+
58
+ **Implemented enhancements:**
59
+
60
+ - Update README
61
+ - Update binstub to check non-rails config file
62
+
63
+ **Fixed bugs:**
64
+
65
+ - Fix README
66
+
67
+ **Miscellaneous:**
68
+
69
+ - Bump release-notes to 1.1.1
70
+
71
+ ## v1.1.0
72
+
73
+ **Implemented enhancements:**
74
+
75
+ - Light refactoring and add binstub and non-rails install
76
+
77
+ **Miscellaneous:**
78
+
79
+ - Bump release-notes to 1.1.0
80
+
81
+ ## v1.0.1
82
+
83
+ **Implemented enhancements:**
84
+
85
+ - Update README.md
86
+ - Updates to README, CONTRIBUTING and add bin/test
87
+ - Update README and install template
88
+
89
+ **Fixed bugs:**
90
+
91
+ - Remove environment from rake task
92
+ - Fix contributing.md
93
+ - Fix linking/writing of none linked lines and frozen string modification
94
+ - Fix guard clause for rubocop
95
+
96
+ **Miscellaneous:**
97
+
98
+ - Bump release-notes to 1.0.1
99
+ - Bump release-notes to 1.0.0
100
+
101
+ ## v1.0.0.pre
102
+
103
+ ## v1.0.0
104
+
105
+ **Implemented enhancements:**
106
+
107
+ - Update README
108
+ - Add log_all option for configuration
109
+ - Add force_rewrite option to configuration
110
+ - Fix linking not adding the issue number correctly
111
+ - Add GH templates
112
+ - Add test around puts on rake task
113
+ - Refactor link.rb and increase test coverage
114
+ - Add rubocop & fix cops
115
+ - ignore .ruby-version since it's irrelevant and add different rubies to travis
116
+ - ruby version update -> 2.5.3
117
+ - Update README
118
+
119
+ **Fixed bugs:**
120
+
121
+ - Fix cops and depreciation warnings
122
+ - Fix spelling error
123
+ - Reduce cyclomatic complexity of Write.rb
124
+ - Remove extra new line on output
125
+ - Remove extra header underline on output md file
126
+ - fix readme typo
127
+
128
+ **Miscellaneous:**
129
+
130
+ - Bump release-notes to 1.0.0.pre
131
+ - Utilize bundler caching on travis
132
+
133
+ ## v0.1.0
134
+
135
+ **Implemented enhancements:**
136
+
137
+ - Update prettify class
138
+ - update readme
139
+ - Update to linking commit messages
140
+ - Minor updates to layout of gem
141
+ - more readme updates
142
+ - add docs badge to readme
143
+ - add yard config
144
+ - update readme
145
+ - WIP adding test coverage to code climate
146
+ - Add badges to README
147
+ - Add some initial tests
@@ -1,24 +1,41 @@
1
- # Contributor Code of Conduct
1
+ # Code of Conduct
2
2
 
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
7
4
 
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
12
22
 
13
23
  Examples of unacceptable behavior by participants include:
14
24
 
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
22
39
 
23
40
  Project maintainers have the right and responsibility to remove, edit, or
24
41
  reject comments, commits, code, wiki edits, issues, and other contributions
@@ -26,24 +43,34 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
26
43
  permanently any contributor for other behaviors that they deem inappropriate,
27
44
  threatening, offensive, or harmful.
28
45
 
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
46
+ ## Scope
33
47
 
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
36
56
 
37
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at dvmonroe6@gmail.com. All
58
+ reported by contacting the project maintainer at dvmonroe6@gmail.com. All
39
59
  complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
43
72
 
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
73
+ [homepage]: https://www.contributor-covenant.org
47
74
 
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
data/README.md CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  # Release::Notes
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/release-notes.svg)](https://badge.fury.io/rb/release-notes)
6
+ [![Documentation](http://img.shields.io/badge/rdoc-Release::Notes-blue.svg)](https://www.rubydoc.info/gems/release-notes)
7
+ [![Inline docs](http://inch-ci.org/github/dvmonroe/release-notes.svg?branch=master)](http://inch-ci.org/github/dvmonroe/release-notes)
8
+
5
9
  [![Build Status](https://travis-ci.org/dvmonroe/release-notes.svg?branch=master)](https://travis-ci.org/dvmonroe/release-notes)
6
10
  [![Code Climate](https://codeclimate.com/github/dvmonroe/release-notes/badges/gpa.svg)](https://codeclimate.com/github/dvmonroe/release-notes)
7
11
  [![Test Coverage](https://codeclimate.com/github/dvmonroe/release-notes/badges/coverage.svg)](https://codeclimate.com/github/dvmonroe/release-notes/coverage)
8
- [![Inline docs](http://inch-ci.org/github/dvmonroe/release-notes.svg?branch=master)](http://inch-ci.org/github/dvmonroe/release-notes)
9
12
 
10
13
  ## Automated release notes based on your project's git log.
11
14
 
@@ -65,7 +68,6 @@ Release::Notes.configure do |config|
65
68
  config.temp_file = './release-notes.tmp.md'
66
69
  config.include_merges = false
67
70
  config.ignore_case = true
68
- config.log_format = '- %s'
69
71
  config.extended_regex = true
70
72
  config.header_title = "tag"
71
73
  config.bug_labels = %w(Fix Update)
@@ -80,13 +82,14 @@ Release::Notes.configure do |config|
80
82
  config.link_to_humanize = %w()
81
83
  config.link_to_sites = %w()
82
84
  config.timezone = 'America/New_York'
83
- config.prettify_messages = true
85
+ config.prettify_messages = false
84
86
  config.force_rewrite = false
87
+ config.single_label = true
85
88
  end
86
89
  ```
87
90
 
88
91
  For more information about each individual setting checkout Release::Notes's
89
- [config docs](http://www.rubydoc.info/github/dvmonroe/release-notes/master/Release/Notes/Configuration).
92
+ [config docs](https://www.rubydoc.info/gems/release-notes).
90
93
 
91
94
  ## Usage
92
95
 
@@ -159,7 +162,6 @@ Useful information can be found here regarding the
159
162
  - Linking is opinionated and will link to a URI structure of `#{site-url}/#{issue_number}`. It
160
163
  will ouput something like: `[HONEYBADGER #33150353](https://app.honeybadger.io/projects/9999/faults/33150353)`.
161
164
  This also means that your link_to_labels have to be something like `['HB #']` (PR's to make this more flexible are welcome)
162
- - We grep the entire commit message when generating the release notes file. If you include keywords in your commit subject and message that match multiple configured labels, that commit will be listed under all relevant label headers, which could lead to commits being listed under more than one label.
163
165
 
164
166
  ## Development
165
167
 
@@ -167,7 +169,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
167
169
 
168
170
  ## Contributing
169
171
 
170
- 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 [Contributing Guide](https://github.com/dvmonroe/release-notes/CONTRIBUTING.md).
172
+ 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 [Contributing Guide](https://github.com/dvmonroe/release-notes/blob/master/CONTRIBUTING.md).
171
173
 
172
174
  ## License
173
175
 
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "pathname"
5
+ require "fileutils"
6
+ require "active_support/core_ext/string"
7
+ require_relative "../lib/release/notes/version"
8
+
9
+ # path to your application root.
10
+ APP_ROOT = Pathname.new File.expand_path("..", __dir__)
11
+ MASTER_CHECK = <<~MASTER_CHECK
12
+ if [ $(git symbolic-ref --short -q HEAD) != 'master' ];
13
+ then exit 1;
14
+ fi
15
+ MASTER_CHECK
16
+ VERSION_TYPES = %w(major minor patch).freeze
17
+
18
+ def system!(*args)
19
+ system(*args) || abort("\n== Command #{args} failed ==")
20
+ end
21
+
22
+ abort("\n== Version Type incorrect ==") unless VERSION_TYPES.include?(ARGV[0])
23
+
24
+ abort("\n== Not on master") unless system(MASTER_CHECK)
25
+
26
+ current_version = Release::Notes::VERSION.split(".").map(&:to_i)
27
+
28
+ case ARGV[0]
29
+ when "major"
30
+ current_version[0] += 1
31
+ current_version[1] = 0
32
+ current_version[2] = 0
33
+ when "minor"
34
+ current_version[1] += 1
35
+ current_version[2] = 0
36
+ when "patch"
37
+ current_version[2] += 1
38
+ end
39
+
40
+ FileUtils.chdir APP_ROOT do
41
+ contents = <<~FILE
42
+ # frozen_string_literal: true
43
+
44
+ module Release
45
+ module Notes
46
+ VERSION = "#{current_version.join('.')}"
47
+ end
48
+ end
49
+ FILE
50
+
51
+
52
+ puts "== Updating version to #{current_version.join('.')} =="
53
+ File.write("lib/release/notes/version.rb", contents)
54
+
55
+ puts "== Adding Changed Files =="
56
+ system! "git add ."
57
+
58
+ puts "== Committing updated files =="
59
+ system! "git commit -m 'Version bump to #{current_version.join('.')}'"
60
+
61
+ puts "== Tagging release =="
62
+ 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
@@ -24,12 +24,6 @@ Release::Notes.configure do |config|
24
24
  # @return [Boolean]
25
25
  # config.ignore_case = true
26
26
 
27
- # Allows you to specify what information you want to print from your git log
28
- # Defaults to `%s` for subject. For more, see
29
- # [Git Log Docs](https://git-scm.com/docs/git-log)
30
- # @return [String]
31
- # config.log_format = "- %s"
32
-
33
27
  # Consider the limiting patterns to be extended regular expressions patterns
34
28
  # when printing your git log.
35
29
  # Defaults to `true`. For more, see
@@ -115,12 +109,19 @@ Release::Notes.configure do |config|
115
109
 
116
110
  # Controls whether your commit subject labels should be removed from the final
117
111
  # ouput of your message on the generated log.
118
- # Defaults to `true`.
112
+ # Defaults to `false`.
119
113
  # @return [Boolean]
120
- # config.prettify_messages = true
114
+ # config.prettify_messages = false
121
115
 
122
116
  # Controls whether to rewrite the output file or append to it.
123
117
  # Defaults to `false`.
124
118
  # @return [Boolean]
125
119
  # config.force_rewrite = false
120
+
121
+ # If a commit message contains words that match more than
122
+ # one group of labels as defined in your configuration, the output
123
+ # will only contain the commit once.
124
+ # Defaults to `true`.
125
+ # @return [Boolean]
126
+ # attr_accessor :single_label
126
127
  end
@@ -33,12 +33,6 @@ module Release
33
33
  # @return [Boolean]
34
34
  attr_accessor :extended_regex
35
35
 
36
- # Allows you to specify what information you want to print from your git log
37
- # Defaults to `%s` for subject. For more, see
38
- # [Git Log Docs](https://git-scm.com/docs/git-log)
39
- # @return [String]
40
- attr_accessor :log_format
41
-
42
36
  # Controls the headers that will be used for your tags
43
37
  # Defaults to `tag`.
44
38
  # @return [String]
@@ -116,7 +110,7 @@ module Release
116
110
 
117
111
  # Controls whether your commit subject labels should be removed from the final
118
112
  # ouput of your message on the generated log.
119
- # Defaults to `true`.
113
+ # Defaults to `false`.
120
114
  # @return [Boolean]
121
115
  attr_accessor :prettify_messages
122
116
 
@@ -125,13 +119,19 @@ module Release
125
119
  # @return [Boolean]
126
120
  attr_accessor :force_rewrite
127
121
 
122
+ # If a commit message contains words that match more than
123
+ # one group of labels as defined in your configuration, the output
124
+ # will only contain the commit once.
125
+ # Defaults to `true`.
126
+ # @return [Boolean]
127
+ attr_accessor :single_label
128
+
128
129
  def initialize
129
130
  @output_file = "./RELEASE_NOTES.md"
130
131
  @temp_file = "./release-notes.tmp.md"
131
132
  @include_merges = false
132
133
  @ignore_case = true
133
134
  @extended_regex = true
134
- @log_format = "- %s"
135
135
  @header_title = "tag"
136
136
  @bug_labels = %w(Fix Update)
137
137
  @feature_labels = %w(Add Create)
@@ -145,8 +145,9 @@ module Release
145
145
  @link_to_humanize = %w()
146
146
  @link_to_sites = %w()
147
147
  @timezone = "America/New_York"
148
- @prettify_messages = true
148
+ @prettify_messages = false
149
149
  @force_rewrite = false
150
+ @single_label = true
150
151
  end
151
152
 
152
153
  # @return [String]
@@ -205,7 +206,6 @@ module Release
205
206
  @prettify_messages
206
207
  end
207
208
 
208
- # :nocov:
209
209
  private
210
210
 
211
211
  # @api private
@@ -236,6 +236,5 @@ module Release
236
236
  def self.configure
237
237
  yield configuration
238
238
  end
239
- # :nocov:
240
239
  end
241
240
  end
@@ -8,17 +8,25 @@ module Release
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  included do
11
- delegate :all_labels, :log_format, :grep_insensitive?,
11
+ delegate :all_labels, :grep_insensitive?,
12
12
  :regex_type, :include_merges?, to: :"Release::Notes.configuration"
13
13
 
14
14
  def log(**opts)
15
15
  "git log '#{opts[:tag_from]}'..'#{opts[:tag_to]}'" \
16
16
  " --grep='#{opts[:label]}#{opts[:invert_grep]}'" \
17
17
  " #{regex_type} #{grep_insensitive?}" \
18
- " #{include_merges?} --format='#{log_format}'"
18
+ " #{include_merges?} --format='%h #{log_format}'"
19
19
  end
20
20
  end
21
21
 
22
+ def log_format
23
+ "- %s"
24
+ end
25
+
26
+ def first_commit
27
+ "git rev-list --max-parents=0 HEAD"
28
+ end
29
+
22
30
  def last_tag
23
31
  "git describe --abbrev=0 --tags"
24
32
  end
@@ -28,7 +36,7 @@ module Release
28
36
  end
29
37
 
30
38
  def read_all_tags
31
- "git tags | sort -u -r"
39
+ "git tag | sort -u -r"
32
40
  end
33
41
  end
34
42
  end
@@ -14,7 +14,6 @@ module Release
14
14
  @new_lines
15
15
  end
16
16
 
17
- # :nocov:
18
17
  private
19
18
 
20
19
  # @api private
@@ -61,7 +60,6 @@ module Release
61
60
  line.gsub! identifier, linked
62
61
  line
63
62
  end
64
- # :nocov:
65
63
  end
66
64
  end
67
65
  end
@@ -4,21 +4,16 @@ module Release
4
4
  module Notes
5
5
  class Log
6
6
  include System
7
-
8
- attr_reader :writer, :date_formatter
9
- attr_reader :all_tags
10
-
11
7
  delegate :force_rewrite, :all_labels, :log_all, :header_title,
12
8
  :header_title_type, :features, :bugs, :misc, :feature_title,
13
- :bug_title, :misc_title, :log_all_title,
9
+ :bug_title, :misc_title, :log_all_title, :single_label,
14
10
  :release_notes_exist?, to: :"Release::Notes.configuration"
15
11
 
16
12
  delegate :date_humanized, :format_tag_date, to: :date_formatter
17
13
  delegate :digest_header, :digest_title, to: :writer
18
14
 
19
15
  def initialize
20
- @writer = Release::Notes::Write.new
21
- @date_formatter = Release::Notes::DateFormat.new
16
+ @_commits = []
22
17
  end
23
18
 
24
19
  def perform
@@ -34,41 +29,34 @@ module Release
34
29
  writer.write_new_file
35
30
  end
36
31
 
37
- # :nocov:
38
32
  private
39
33
 
40
- def git_all_tags
41
- @git_all_tags ||= System.all_tags.split("\n")
42
- # return Error.new(msg: :missing_tags) unless all_tags.present?
43
- end
44
-
45
34
  # @api private
46
35
  def copy_single_tag_of_activity(tag_from:, tag_to: "HEAD")
47
36
  [features, bugs, misc].each_with_index do |regex, i|
48
- log = system_log(
49
- tag_from: tag_from,
50
- tag_to: tag_to,
51
- label: regex,
52
- log_all: false,
53
- )
54
- digest_title(title: titles[i], log_message: log) if log.present?
37
+ log = system_log(tag_from: tag_from, tag_to: tag_to, label: regex, log_all: log_all)
38
+ log_grouped_commits(title: titles[i], log: log)
55
39
  end
56
40
 
57
41
  return unless log_all
58
42
 
59
- log = system_log(
60
- tag_from: tag_from,
61
- tag_to: tag_to,
62
- log_all: true,
63
- )
64
- digest_title(title: log_all_title, log_message: log) if log.present?
43
+ log = system_log(tag_from: tag_from, tag_to: tag_to)
44
+ log_grouped_commits(title: log_all_title, log: log)
65
45
  end
66
46
 
67
47
  # @api private
68
- def find_last_tag_and_log
69
- last_tag = system_last_tag.delete!("\n")
70
- return false unless system_log(tag_from: last_tag, label: all_labels).present?
48
+ def date_formatter
49
+ @date_formatter ||= Release::Notes::DateFormat.new
50
+ end
71
51
 
52
+ # @api private
53
+ def find_last_tag_and_log
54
+ last_tag = system_last_tag.strip
55
+ # return false unless system_log(tag_from: last_tag, label: all_labels).present?
56
+ if system_log(tag_from: last_tag, label: all_labels).blank?
57
+ log_last
58
+ return
59
+ end
72
60
  # output the date right now
73
61
  header_content date: date_humanized, tag: tag_to
74
62
  copy_single_tag_of_activity(tag_from: last_tag)
@@ -77,25 +65,79 @@ module Release
77
65
  # @api private
78
66
  def find_all_tags_and_log_all
79
67
  git_all_tags.each_with_index do |ta, i|
80
- previous_tag = git_all_tags[i + 1]
81
- next unless previous_tag.present? &&
82
- system_log(tag_from: previous_tag, tag_to: ta, label: all_labels).present?
68
+ header_content(
69
+ date: date_humanized(date: System.tag_date(tag: ta)),
70
+ tag: ta,
71
+ )
83
72
 
84
- header_content date: date_humanized(date: System.tag_date(tag: ta)), tag: ta
85
- copy_single_tag_of_activity(tag_from: previous_tag, tag_to: ta)
73
+ copy_single_tag_of_activity(
74
+ tag_from: previous_tag(i).strip,
75
+ tag_to: ta,
76
+ )
86
77
  end
87
78
  end
88
79
 
80
+ # @api private
81
+ def log_last
82
+ header_content date: date_humanized, tag: git_all_tags[0]
83
+ copy_single_tag_of_activity(tag_from: git_all_tags[1], tag_to: git_all_tags[0])
84
+ end
85
+
86
+ # @api private
87
+ def git_all_tags
88
+ @git_all_tags ||= System.all_tags.split("\n")
89
+ end
90
+
89
91
  # @api private
90
92
  def header_content(**date_and_tag)
91
93
  digest_header(date_and_tag[header_title_type.to_sym])
92
94
  end
93
95
 
96
+ # @api private
97
+ def log_grouped_commits(log:, title:)
98
+ return unless log.present?
99
+
100
+ log_messages = log.split("\n").map { |x| x.split(/(?=-)/) }
101
+ commit_hashes = log_messages.flat_map { |msg| msg[0].strip }
102
+
103
+ trimmed_commit_hashes = trim_commit_hashes(commit_hashes)
104
+
105
+ digest_unique_messages(log_messages, trimmed_commit_hashes, title) if trimmed_commit_hashes.present?
106
+ end
107
+
108
+ # @api private
109
+ def digest_unique_messages(log_messages, commit_hashes, title)
110
+ messages = log_messages.map do |msg|
111
+ msg[1..-1].join if commit_hashes.include?(msg[0].strip)
112
+ end.compact
113
+
114
+ @_commits += commit_hashes
115
+
116
+ digest_title(title: title, log_message: "#{messages.join("\n")}\n")
117
+ end
118
+
119
+ # @api private
120
+ def trim_commit_hashes(commit_hashes)
121
+ commit_hashes.dup.each do |commit|
122
+ commit_hashes.delete commit if single_label && @_commits.include?(commit)
123
+ end
124
+ commit_hashes
125
+ end
126
+
127
+ # @api private
128
+ def previous_tag(index)
129
+ git_all_tags[index + 1].present? ? git_all_tags[index + 1] : System.first_commit
130
+ end
131
+
94
132
  # @api private
95
133
  def titles
96
134
  [feature_title, bug_title, misc_title]
97
135
  end
98
- # :nocov:
136
+
137
+ # @api private
138
+ def writer
139
+ @writer ||= Release::Notes::Write.new
140
+ end
99
141
  end
100
142
  end
101
143
  end
@@ -13,14 +13,12 @@ module Release
13
13
  end
14
14
  end
15
15
 
16
- # :nocov:
17
16
  private
18
17
 
19
18
  # @api private
20
19
  def labels_regex
21
20
  Regexp.new all_labels, Regexp::IGNORECASE
22
21
  end
23
- # :nocov:
24
22
  end
25
23
  end
26
24
  end
@@ -21,6 +21,10 @@ module Release
21
21
  end
22
22
  end
23
23
 
24
+ def first_commit
25
+ `#{Git.first_commit}`
26
+ end
27
+
24
28
  def all_tags
25
29
  `#{Git.read_all_tags}`
26
30
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Release
4
4
  module Notes
5
- VERSION = "1.3.0"
5
+ VERSION = "2.0.0"
6
6
  end
7
7
  end
@@ -45,7 +45,6 @@ module Release
45
45
  FileUtils.rm temp_file
46
46
  end
47
47
 
48
- # :nocov:
49
48
  private
50
49
 
51
50
  # @api private
@@ -91,7 +90,6 @@ module Release
91
90
  fi << "# Release Notes\n"
92
91
  end
93
92
  end
94
- # :nocov:
95
93
  end
96
94
  end
97
95
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "http://github.com/dvmonroe/release-notes"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|config)/}) }
17
17
  spec.bindir = "exe"
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.12"
24
24
  spec.add_development_dependency "pry", "~> 0.12.2"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rubocop", "~> 0.60.0"
26
+ spec.add_development_dependency "rubocop", "~> 0.61.0"
27
27
  end
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: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Monroe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-07 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.60.0
75
+ version: 0.61.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.60.0
82
+ version: 0.61.0
83
83
  description: Generate automated release notes for any project
84
84
  email:
85
85
  - dvmonroe6@gmail.com
@@ -88,6 +88,7 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".codeclimate.yml"
91
92
  - ".github/ISSUE_TEMPLATE.md"
92
93
  - ".github/PULL_REQUEST_TEMPLATE.md"
93
94
  - ".gitignore"
@@ -95,6 +96,7 @@ files:
95
96
  - ".rubocop.yml"
96
97
  - ".travis.yml"
97
98
  - ".yardopts"
99
+ - CHANGELOG.md
98
100
  - CODE_OF_CONDUCT.md
99
101
  - CONTRIBUTING.md
100
102
  - Gemfile
@@ -102,6 +104,7 @@ files:
102
104
  - README.md
103
105
  - Rakefile
104
106
  - bin/console
107
+ - bin/publish
105
108
  - bin/setup
106
109
  - bin/test
107
110
  - exe/release-notes
@@ -143,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
146
  version: '0'
144
147
  requirements: []
145
148
  rubyforge_project:
146
- rubygems_version: 2.7.6
149
+ rubygems_version: 2.7.3
147
150
  signing_key:
148
151
  specification_version: 4
149
152
  summary: Automated release notes for your project