easy_changelog 0.1.0
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 +7 -0
- data/.env +1 -0
- data/.rubocop.yml +17 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +7 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +21 -0
- data/README.md +88 -0
- data/Rakefile +21 -0
- data/easy-changelog.gemspec +35 -0
- data/lib/easy_changelog/configuration.rb +73 -0
- data/lib/easy_changelog/entry.rb +98 -0
- data/lib/easy_changelog/railtie.rb +14 -0
- data/lib/easy_changelog/task_options_parser.rb +29 -0
- data/lib/easy_changelog/tasks/changelog.rake +39 -0
- data/lib/easy_changelog/version.rb +5 -0
- data/lib/easy_changelog.rb +124 -0
- data/sig/easy_changelog.rbs +4 -0
- metadata +66 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 236711ac036de2a58700baeceed154cd1bd88366572c6079035709e21d998704
|
|
4
|
+
data.tar.gz: 48440bccef6c26da9dab7b7ca2194af70a3f2880eb4bd4d540d5af4ab63161f8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 41e7ac1c2b79337413818350b4f014ba03e966271538c8b009b867c62509ea8ca16b481c4c34a4b7298e32d2284afb961d82b192ed1308a42cfb0bf87a63f3e6
|
|
7
|
+
data.tar.gz: de76095801aca8f3c54323d357e980b20657334c632d3333644324b4d1cdb51a5445fb782a5f9f035564aff816c2a445aa994e3e992805f9369b5f0c08e8e40d
|
data/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
REPOSITORY_URL = 'https://github.com/ivan05almeida/easy_changelog'
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.6
|
|
3
|
+
NewCops: enable
|
|
4
|
+
|
|
5
|
+
Style/Documentation:
|
|
6
|
+
Enabled: false
|
|
7
|
+
|
|
8
|
+
Style/StringLiterals:
|
|
9
|
+
Enabled: true
|
|
10
|
+
EnforcedStyle: single_quotes
|
|
11
|
+
|
|
12
|
+
Style/StringLiteralsInInterpolation:
|
|
13
|
+
Enabled: true
|
|
14
|
+
EnforcedStyle: double_quotes
|
|
15
|
+
|
|
16
|
+
Layout/LineLength:
|
|
17
|
+
Max: 120
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.8
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## master (unreleased)
|
|
4
|
+
### New features
|
|
5
|
+
|
|
6
|
+
* [#b0faf01](https://github.com/ivan05almeida/easy_changelog/commit/b0faf01): Initialize EasyChangelog gem. ([@ivan05almeida][])
|
|
7
|
+
* [#1763186](https://github.com/ivan05almeida/easy_changelog/commit/1763186): Update Readme. ([@ivan05almeida][])
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
+
advances of any kind
|
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
* Public or private harassment
|
|
25
|
+
* Publishing others' private information, such as a physical or email
|
|
26
|
+
address, without their explicit permission
|
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
+
professional setting
|
|
29
|
+
|
|
30
|
+
## Enforcement Responsibilities
|
|
31
|
+
|
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
+
|
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
+
|
|
40
|
+
## Enforcement
|
|
41
|
+
|
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ivan.filho@avenuecode.com. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
+
|
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
+
|
|
46
|
+
## Enforcement Guidelines
|
|
47
|
+
|
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
+
|
|
50
|
+
### 1. Correction
|
|
51
|
+
|
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
+
|
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
+
|
|
56
|
+
### 2. Warning
|
|
57
|
+
|
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
+
|
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
+
|
|
62
|
+
### 3. Temporary Ban
|
|
63
|
+
|
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
+
|
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
+
|
|
68
|
+
### 4. Permanent Ban
|
|
69
|
+
|
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
+
|
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
+
|
|
74
|
+
## Attribution
|
|
75
|
+
|
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
+
|
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
+
|
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
|
82
|
+
|
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
easy_changelog (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.2)
|
|
10
|
+
dotenv (2.8.1)
|
|
11
|
+
json (2.9.1)
|
|
12
|
+
language_server-protocol (3.17.0.3)
|
|
13
|
+
minitest (5.25.4)
|
|
14
|
+
parallel (1.26.3)
|
|
15
|
+
parser (3.3.7.0)
|
|
16
|
+
ast (~> 2.4.1)
|
|
17
|
+
racc
|
|
18
|
+
racc (1.8.1)
|
|
19
|
+
rainbow (3.1.1)
|
|
20
|
+
rake (13.2.1)
|
|
21
|
+
regexp_parser (2.10.0)
|
|
22
|
+
rubocop (1.70.0)
|
|
23
|
+
json (~> 2.3)
|
|
24
|
+
language_server-protocol (>= 3.17.0)
|
|
25
|
+
parallel (~> 1.10)
|
|
26
|
+
parser (>= 3.3.0.2)
|
|
27
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
28
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
29
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
|
30
|
+
ruby-progressbar (~> 1.7)
|
|
31
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
32
|
+
rubocop-ast (1.37.0)
|
|
33
|
+
parser (>= 3.3.1.0)
|
|
34
|
+
ruby-progressbar (1.13.0)
|
|
35
|
+
unicode-display_width (3.1.4)
|
|
36
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
37
|
+
unicode-emoji (4.0.4)
|
|
38
|
+
|
|
39
|
+
PLATFORMS
|
|
40
|
+
x86_64-darwin-20
|
|
41
|
+
|
|
42
|
+
DEPENDENCIES
|
|
43
|
+
dotenv (~> 2.7)
|
|
44
|
+
easy_changelog!
|
|
45
|
+
minitest (~> 5.0)
|
|
46
|
+
rake (~> 13.0)
|
|
47
|
+
rubocop (~> 1.56)
|
|
48
|
+
|
|
49
|
+
BUNDLED WITH
|
|
50
|
+
2.3.25
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ivan de Paula Almeida Filho
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# EasyChangelog
|
|
2
|
+
|
|
3
|
+
<strong>EasyChangelog</strong> is a tool easily manage your project changelog. This project is based on Rubocop changelog style with more customizations to your needs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
8
|
+
|
|
9
|
+
$ bundle add easy_changelog
|
|
10
|
+
|
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
12
|
+
|
|
13
|
+
$ gem install easy_changelog
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Configuration
|
|
18
|
+
|
|
19
|
+
Write an easy_changelog.rb at the initiliazers folder in order to config the gem accordingly to your project
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
EasyChangelog.configure do |config|
|
|
23
|
+
config.entries_path = 'changelog/' # the folder where the changelog entries will be stored
|
|
24
|
+
config.changelog_filename = 'CHANGELOG.md' # the filename of your changelog
|
|
25
|
+
config.main_branch = 'master' # main branch for repository
|
|
26
|
+
config.filename_max_length = 50 # max filename length
|
|
27
|
+
config.include_empty_task_id = false # includes a [] when task id and the project still need to track tasks without tickets
|
|
28
|
+
|
|
29
|
+
config.unreleased_header = '## master (unreleased)' # Header of changelog where the unreleased entries are located
|
|
30
|
+
config.user_signature = /\[@([\w-]+)\]\[\]/ # Regexp to list unique contributors of the project
|
|
31
|
+
|
|
32
|
+
config.type_mapping = { # Entry types and their Section Names to be displayed at Changelog
|
|
33
|
+
new: 'New features',
|
|
34
|
+
fix: 'Bug fixes'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
config.repo_url = <GITHUB_REPO_URL> # URL to your repository (Can also be defined with REPOSITORY_URL var var)
|
|
38
|
+
config.tasks_url = <YOUR_ISSUE_TRACKING_URL> # URL to your organization issue tracker (ex: JIRA, Asana, Wrike. Can also be defined with REPOSITORY_URL env var)
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Entries Types
|
|
43
|
+
|
|
44
|
+
By default this gem supports new and fix changelog entries. Check the Configuration section to see how you can change this with type_mapping option.
|
|
45
|
+
|
|
46
|
+
For each supported type, you can call their rake task:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
$ bundle exec rake changelog:new -- --ref-id=1234 --ref-type=pull
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
To know all options available you can add `--help` option to the command
|
|
53
|
+
|
|
54
|
+
By default if a ref id is given the ref-type default will be pull, if it's blank it will be commit and the changelog will then contain reference with the short git commit ID instead.
|
|
55
|
+
|
|
56
|
+
You can still pass a ref-id and set ref-type to issues to add a reference to a issue card
|
|
57
|
+
|
|
58
|
+
### Prepare changelog to deployment/release
|
|
59
|
+
|
|
60
|
+
To add the entries to your changelog just need to run
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
$ bundle exec rake changelog:merge
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If you want to check if there are entries to merge:
|
|
67
|
+
```
|
|
68
|
+
$ bundle exec rake changelog:check_clean
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
75
|
+
|
|
76
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
77
|
+
|
|
78
|
+
## Contributing
|
|
79
|
+
|
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/easy_changelog. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/easy_changelog/blob/main/CODE_OF_CONDUCT.md).
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
85
|
+
|
|
86
|
+
## Code of Conduct
|
|
87
|
+
|
|
88
|
+
Everyone interacting in the Ruby::Changelog project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/easy_changelog/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << 'test'
|
|
8
|
+
t.libs << 'lib'
|
|
9
|
+
t.test_files = FileList['test/**/test_*.rb']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'rubocop/rake_task'
|
|
13
|
+
|
|
14
|
+
RuboCop::RakeTask.new
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
path = File.expand_path(__dir__)
|
|
18
|
+
Dir.glob("#{path}/lib/easy_changelog/tasks/**/*.rake").each { |f| import f }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
task default: %i[test rubocop]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/easy_changelog/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'easy_changelog'
|
|
7
|
+
spec.version = EasyChangelog::VERSION
|
|
8
|
+
spec.authors = ['Ivan de Paula Almeida Filho']
|
|
9
|
+
spec.email = ['ivan05filho@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Small tool to generate a changelog file based on git commits.'
|
|
12
|
+
spec.description = 'Changelog generator, based on Rubocop contributing section.'
|
|
13
|
+
spec.homepage = 'https://github.com/ivan05almeida/easy_changelog'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 2.6.0'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = 'exe'
|
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ['lib']
|
|
31
|
+
|
|
32
|
+
# For more information and examples about making a new gem, check out our
|
|
33
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
34
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
35
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'dotenv/load'
|
|
4
|
+
|
|
5
|
+
class EasyChangelog
|
|
6
|
+
class Configuration
|
|
7
|
+
attr_accessor :changelog_filename, :main_branch, :filename_max_length, :include_empty_task_id, :tasks_url
|
|
8
|
+
attr_reader :entries_path, :unreleased_header, :entry_path_format, :user_signature, :type_mapping
|
|
9
|
+
attr_writer :repo_url, :tasks_url
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@entries_path = 'changelog/'
|
|
13
|
+
@changelog_filename = 'CHANGELOG.md'
|
|
14
|
+
|
|
15
|
+
@main_branch = 'master'
|
|
16
|
+
@entry_path_format = '<type>_<name>_<timestamp>.md'
|
|
17
|
+
@unreleased_header = /#{Regexp.escape("## #{@main_branch} (unreleased)")}/m
|
|
18
|
+
@user_signature = Regexp.new(format(Regexp.escape('[@%<user>s][]'), user: '([\w-]+)'))
|
|
19
|
+
|
|
20
|
+
@filename_max_length = 50
|
|
21
|
+
@type_mapping = { new: 'New features', fix: 'Bug fixes' }
|
|
22
|
+
@include_empty_task_id = false
|
|
23
|
+
|
|
24
|
+
@repo_url = ENV.fetch('REPOSITORY_URL', nil)
|
|
25
|
+
@tasks_url = ENV.fetch('TASKS_URL', nil)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def repo_url
|
|
29
|
+
raise ConfigurationError, 'repo_url must be set' unless @repo_url
|
|
30
|
+
|
|
31
|
+
@repo_url
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def unreleased_header=(value)
|
|
35
|
+
@unreleased_header = /#{Regexp.escape(value)}/m
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def entries_path=(value)
|
|
39
|
+
value += '/' unless value.end_with?('/')
|
|
40
|
+
|
|
41
|
+
@entries_path = value
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def type_mapping=(value)
|
|
45
|
+
raise ArgumentError, 'type_mapping must be a Hash' unless value.is_a?(Hash)
|
|
46
|
+
|
|
47
|
+
@type_mapping = value
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def user_signature=(value)
|
|
51
|
+
raise ArgumentError, 'user_signature must be a Regexp' unless value.is_a?(Regexp)
|
|
52
|
+
|
|
53
|
+
@user_signature = value
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def changelog_types
|
|
57
|
+
@type_mapping.keys
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def entry_path_match_regexp
|
|
61
|
+
formula = @entry_path_format.gsub(/<(\w+)>/) do |match|
|
|
62
|
+
matcher = match == '<type>' ? '[^_]' : '.'
|
|
63
|
+
"(?#{match}#{matcher}+)"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
Regexp.new("(?:#{entries_path})?#{formula}")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def entry_path_template
|
|
70
|
+
File.join(entries_path, @entry_path_format.gsub(/<(\w+)>/) { |_match| "%<#{Regexp.last_match(1)}>s" })
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class EasyChangelog
|
|
4
|
+
Entry = Struct.new(:type, :body, :ref_type, :ref_id, :task_id, :tasks_url, :user, keyword_init: true) do
|
|
5
|
+
def initialize(type:, body: last_commit_title, ref_type: nil, ref_id: nil, task_id: nil, tasks_url: nil,
|
|
6
|
+
user: github_user)
|
|
7
|
+
id, body = extract_id(body)
|
|
8
|
+
ref_id ||= id || last_commit_id
|
|
9
|
+
ref_type ||= id ? :pull : :commit
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def write
|
|
14
|
+
dir_name = EasyChangelog.configuration.entries_path
|
|
15
|
+
FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
|
|
16
|
+
|
|
17
|
+
File.write(path, content)
|
|
18
|
+
path
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def path
|
|
22
|
+
format(
|
|
23
|
+
EasyChangelog.configuration.entry_path_template,
|
|
24
|
+
type: type, name: str_to_filename(body), timestamp: Time.now.strftime('%Y%m%d%H%M%S')
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def content
|
|
29
|
+
title = body.dup
|
|
30
|
+
title += '.' unless title.end_with? '.'
|
|
31
|
+
|
|
32
|
+
"* #{ref}: #{task_ref} #{title} ([@#{user}][])\n"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def ref
|
|
36
|
+
raise ArgumentError, 'ref_type must be issues, pull, or commit' unless %w[issues pull commit].include?(ref_type)
|
|
37
|
+
|
|
38
|
+
"[##{ref_id}](#{EasyChangelog.configuration.repo_url}/#{ref_type}/#{ref_id})"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def task_ref
|
|
42
|
+
return EasyChangelog.configuration.include_empty_task_id ? '[] ' : '' if task_id.nil? || task_id.empty?
|
|
43
|
+
|
|
44
|
+
link = "[#{task_id}]"
|
|
45
|
+
base_url = tasks_url || EasyChangelog.configuration.tasks_url
|
|
46
|
+
link += "(#{base_url}/#{task_id})" if base_url
|
|
47
|
+
|
|
48
|
+
link
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def last_commit_title
|
|
52
|
+
`git log -1 --pretty=%B`.lines.first.chomp
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def last_commit_id
|
|
56
|
+
`git log -n1 --format="%h"`.chomp
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def extract_id(body)
|
|
60
|
+
/^\[Fix(?:es)? #(\d+)\] (.*)/.match(body)&.captures || [nil, body]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def str_to_filename(str)
|
|
64
|
+
str
|
|
65
|
+
.split
|
|
66
|
+
.reject(&:empty?)
|
|
67
|
+
.map { |s| prettify(s) }
|
|
68
|
+
.inject do |result, word|
|
|
69
|
+
s = "#{result}_#{word}"
|
|
70
|
+
return result if s.length > EasyChangelog.configuration.filename_max_length
|
|
71
|
+
|
|
72
|
+
s
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def github_user
|
|
77
|
+
user = `git config --global credential.username`.chomp
|
|
78
|
+
warn 'Set your username with `git config --global credential.username "myusernamehere"`' if user.empty?
|
|
79
|
+
|
|
80
|
+
user
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def prettify(str)
|
|
86
|
+
str.gsub!(/\W/, '_')
|
|
87
|
+
|
|
88
|
+
# Separate word boundaries by `_`.
|
|
89
|
+
str.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do
|
|
90
|
+
(Regexp.last_match(1) || Regexp.last_match(2)) << '_'
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
str.gsub!(/\A_+|_+\z/, '')
|
|
94
|
+
str.downcase!
|
|
95
|
+
str
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
|
|
5
|
+
class EasyChangelog
|
|
6
|
+
class TaskOptionsParser
|
|
7
|
+
def self.parse(type, args)
|
|
8
|
+
options = {}
|
|
9
|
+
opts = OptionParser.new
|
|
10
|
+
args = opts.order!(args) {}
|
|
11
|
+
|
|
12
|
+
opts.banner = "Usage: rake changelog:#{type} [options]"
|
|
13
|
+
|
|
14
|
+
opts.on('-r', '--ref-id=ARG', 'Ref ID') { |arg| options[:ref_id] = arg }
|
|
15
|
+
opts.on('-R', '--ref-type=ARG', 'Ref type (issues|pull|commit)') { |arg| options[:ref_type] = arg }
|
|
16
|
+
opts.on('-t', '--task-id=ARG', 'Task ID') { |arg| options[:task_id] = arg }
|
|
17
|
+
opts.on('-T', '--task-url=ARG', 'Tasks URL') { |arg| options[:tasks_url] = arg }
|
|
18
|
+
|
|
19
|
+
opts.on('-h', '--help', 'Prints this helper') do
|
|
20
|
+
puts opts
|
|
21
|
+
exit
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
opts.parse!(args)
|
|
25
|
+
|
|
26
|
+
options
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'easy_changelog'
|
|
4
|
+
require 'easy_changelog/task_options_parser'
|
|
5
|
+
|
|
6
|
+
namespace :changelog do
|
|
7
|
+
EasyChangelog.configuration.changelog_types.each do |type|
|
|
8
|
+
desc "Create a Changelog entry (#{type})"
|
|
9
|
+
task type do
|
|
10
|
+
options = EasyChangelog::TaskOptionsParser.parse(type, ARGV)
|
|
11
|
+
options[:type] = type
|
|
12
|
+
|
|
13
|
+
entry = EasyChangelog::Entry.new(**options)
|
|
14
|
+
path = entry.write
|
|
15
|
+
cmd = "git add #{path}"
|
|
16
|
+
sh cmd
|
|
17
|
+
puts "Entry '#{path}' created and added to git index"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc 'Merge entries and delete them'
|
|
22
|
+
task :merge do
|
|
23
|
+
raise 'No entries!' unless EasyChangelog.pending?
|
|
24
|
+
|
|
25
|
+
EasyChangelog.new.merge!.and_delete!
|
|
26
|
+
cmd = "git commit -a -m 'Update Changelog'"
|
|
27
|
+
puts cmd
|
|
28
|
+
sh cmd
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc 'Check for no pending changelog entries'
|
|
32
|
+
task :check_clean do
|
|
33
|
+
next unless EasyChangelog.pending?
|
|
34
|
+
|
|
35
|
+
puts '*** Pending changelog entries!'
|
|
36
|
+
puts 'Do `bundle exec rake changelog:merge`'
|
|
37
|
+
exit(1)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'easy_changelog/version'
|
|
4
|
+
require 'easy_changelog/configuration'
|
|
5
|
+
require 'easy_changelog/entry'
|
|
6
|
+
|
|
7
|
+
class EasyChangelog
|
|
8
|
+
HEADER = /### (.*)/.freeze
|
|
9
|
+
CONTRIBUTOR = '[@%<user>s]: https://github.com/%<user>s'
|
|
10
|
+
EOF = "\n"
|
|
11
|
+
|
|
12
|
+
class Error < StandardError; end
|
|
13
|
+
class ConfigurationError < StandardError; end
|
|
14
|
+
|
|
15
|
+
require 'easy_changelog/railtie' if defined?(Rails)
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
def configuration
|
|
19
|
+
@configuration ||= EasyChangelog::Configuration.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def configure
|
|
23
|
+
yield(configuration)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def pending?
|
|
27
|
+
entry_paths.any?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def entry_paths
|
|
31
|
+
Dir["#{EasyChangelog.configuration.entries_path}*"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def read_entries
|
|
35
|
+
entry_paths.to_h { |path| [path, File.read(path)] }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize(content: File.read(EasyChangelog.configuration.changelog_filename), entries: EasyChangelog.read_entries)
|
|
40
|
+
require 'strscan'
|
|
41
|
+
|
|
42
|
+
parse(content)
|
|
43
|
+
@entries = entries
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def and_delete!
|
|
47
|
+
@entries.each_key { |path| File.delete(path) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def merge!
|
|
51
|
+
File.write(EasyChangelog.configuration.changelog_filename, merge_content)
|
|
52
|
+
self
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def unreleased_content
|
|
56
|
+
entry_map = parse_entries(@entries)
|
|
57
|
+
merged_map = merge_entries(entry_map)
|
|
58
|
+
merged_map.flat_map { |header, things| ["### #{header}\n", *things, ''] }.join("\n")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def merge_content
|
|
62
|
+
merged_content = [@header, unreleased_content, @rest.chomp, *new_contributor_lines].join("\n")
|
|
63
|
+
|
|
64
|
+
merged_content << EOF
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def new_contributor_lines
|
|
68
|
+
unique_contributor_names = contributors.map { |user| format(CONTRIBUTOR, user: user) }.uniq
|
|
69
|
+
|
|
70
|
+
unique_contributor_names.reject { |line| @rest.include?(line) }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def contributors
|
|
74
|
+
contributors = @entries.values.flat_map do |entry|
|
|
75
|
+
entry.match(/\. \((?<contributors>.+)\)\n/)[:contributors].split(',')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
contributors.join.scan(EasyChangelog.configuration.user_signature).flatten
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def merge_entries(entry_map)
|
|
84
|
+
all = @unreleased.merge(entry_map) { |_k, v1, v2| v1.concat(v2) }
|
|
85
|
+
canonical = EasyChangelog.configuration.type_mapping.values.to_h { |v| [v, nil] }
|
|
86
|
+
canonical.merge(all).compact
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def parse(content)
|
|
90
|
+
ss = StringScanner.new(content)
|
|
91
|
+
|
|
92
|
+
@header = ss.scan_until(EasyChangelog.configuration.unreleased_header)
|
|
93
|
+
@unreleased = parse_release(ss.scan_until(/\n(?=## )/m))
|
|
94
|
+
@rest = ss.rest
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @return [Hash<type, Array<String>]]
|
|
98
|
+
def parse_release(unreleased)
|
|
99
|
+
unreleased
|
|
100
|
+
.lines
|
|
101
|
+
.map(&:chomp)
|
|
102
|
+
.reject(&:empty?)
|
|
103
|
+
.slice_before(HEADER)
|
|
104
|
+
.to_h do |header, *entries|
|
|
105
|
+
[HEADER.match(header)[1], entries]
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def parse_entries(path_content_map)
|
|
110
|
+
changes = Hash.new { |h, k| h[k] = [] }
|
|
111
|
+
|
|
112
|
+
path_content_map.each do |path, content|
|
|
113
|
+
header = EasyChangelog.configuration.type_mapping.fetch(entry_type(path))
|
|
114
|
+
|
|
115
|
+
changes[header].concat(content.lines.map(&:chomp))
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
changes
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def entry_type(path)
|
|
122
|
+
EasyChangelog.configuration.entry_path_match_regexp.match(path)[:type].to_sym
|
|
123
|
+
end
|
|
124
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: easy_changelog
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ivan de Paula Almeida Filho
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-01-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Changelog generator, based on Rubocop contributing section.
|
|
14
|
+
email:
|
|
15
|
+
- ivan05filho@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".env"
|
|
21
|
+
- ".rubocop.yml"
|
|
22
|
+
- ".ruby-version"
|
|
23
|
+
- CHANGELOG.md
|
|
24
|
+
- CODE_OF_CONDUCT.md
|
|
25
|
+
- Gemfile
|
|
26
|
+
- Gemfile.lock
|
|
27
|
+
- LICENSE.txt
|
|
28
|
+
- README.md
|
|
29
|
+
- Rakefile
|
|
30
|
+
- easy-changelog.gemspec
|
|
31
|
+
- lib/easy_changelog.rb
|
|
32
|
+
- lib/easy_changelog/configuration.rb
|
|
33
|
+
- lib/easy_changelog/entry.rb
|
|
34
|
+
- lib/easy_changelog/railtie.rb
|
|
35
|
+
- lib/easy_changelog/task_options_parser.rb
|
|
36
|
+
- lib/easy_changelog/tasks/changelog.rake
|
|
37
|
+
- lib/easy_changelog/version.rb
|
|
38
|
+
- sig/easy_changelog.rbs
|
|
39
|
+
homepage: https://github.com/ivan05almeida/easy_changelog
|
|
40
|
+
licenses:
|
|
41
|
+
- MIT
|
|
42
|
+
metadata:
|
|
43
|
+
homepage_uri: https://github.com/ivan05almeida/easy_changelog
|
|
44
|
+
source_code_uri: https://github.com/ivan05almeida/easy_changelog
|
|
45
|
+
changelog_uri: https://github.com/ivan05almeida/easy_changelog/CHANGELOG.md
|
|
46
|
+
rubygems_mfa_required: 'true'
|
|
47
|
+
post_install_message:
|
|
48
|
+
rdoc_options: []
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 2.6.0
|
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
requirements: []
|
|
62
|
+
rubygems_version: 3.1.6
|
|
63
|
+
signing_key:
|
|
64
|
+
specification_version: 4
|
|
65
|
+
summary: Small tool to generate a changelog file based on git commits.
|
|
66
|
+
test_files: []
|