tag-changelog 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -4
- data/Gemfile.lock +1 -1
- data/README.md +18 -11
- data/bin/tag-changelog +11 -32
- data/lib/tag_changelog.rb +1 -0
- data/lib/tag_changelog/generate.rb +34 -50
- data/lib/tag_changelog/message_list.rb +31 -0
- data/lib/tag_changelog/templates/config.yml +59 -37
- data/lib/tag_changelog/version.rb +1 -1
- data/tag-changelog.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b55176897ce91e86571753da01176a5b0e74cee
|
4
|
+
data.tar.gz: aaaa4cdd9e1d79e2d0090f79947286a7f72d12c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f8c35d82d4109700b0216509febed7f6d27100dd5bfb605b5c8638aa389e3a49a7336c4fdd618bd6d7d6f470121efd9e530c4824574ac76ccf70a1e6bba0175
|
7
|
+
data.tar.gz: c5526369f596e8aeecec098a97ff03ce899989199527d1ae29e54880b969b9060085ee426c5a66ef18588e66afe6161af9de153c943f298d2496c9f61c85d242
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.0.0 (2018-03-12)
|
4
|
+
#### Features
|
5
|
+
* [F] Removes generate command flags in favor of yml config file on project
|
6
|
+
|
7
|
+
## 0.1.0 (2018-02-22)
|
2
8
|
|
3
|
-
Generate this with
|
4
|
-
changelog rdoc
|
5
|
-
After you have described your command line interface
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# tag-changelog
|
2
2
|
|
3
|
-
Tool to generate changelog based on Parallel6 specs
|
3
|
+
Tool to generate changelog based on Parallel6 specs, reading from git history.
|
4
4
|
|
5
5
|
#### NAME
|
6
|
-
tag-changelog - Tool to generate changelog based on
|
6
|
+
tag-changelog - Tool to generate changelog based on git history.
|
7
7
|
|
8
8
|
#### SYNOPSIS
|
9
9
|
tag-changelog [global options] command [command options] [arguments...]
|
10
10
|
|
11
11
|
#### VERSION
|
12
|
-
0.0
|
12
|
+
1.0.0
|
13
13
|
|
14
14
|
#### GLOBAL OPTIONS
|
15
15
|
--help - Show this message
|
@@ -19,6 +19,11 @@ Tool to generate changelog based on Parallel6 specs
|
|
19
19
|
generate - Generate changelog and write to CHANGELOG.md (default).
|
20
20
|
help - Shows a list of commands or help for one command
|
21
21
|
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
```
|
25
|
+
$ gem install tag-changelog
|
26
|
+
```
|
22
27
|
|
23
28
|
## Usage
|
24
29
|
|
@@ -29,15 +34,17 @@ changelog and run:
|
|
29
34
|
$ tag-changelog generate
|
30
35
|
```
|
31
36
|
|
32
|
-
This will execute the `generate` command with the default params.
|
33
|
-
for a list of options you can pass to the command.
|
37
|
+
This will execute the `generate` command with the default params.
|
38
|
+
Please see below for a list of options you can pass to the command.
|
34
39
|
|
35
40
|
#### generate command options
|
36
|
-
-c, --config=file - Configuration file to categorize commit messages in YML format. Must be an absolute path. (default: gem's own config.yml)
|
37
41
|
-d, --dir=directory - Git repository directory (must be an absolute path). Defaults to working directory. (default: current working directory)
|
38
|
-
-f, --filter=regexp - Regexp to categorize commits from git log. (default: (\[+\s?+[cfbhrCFBHR]{1}+\s?+\]))
|
39
|
-
--[no-]group - Group commit messages in categories (defined in configuration file). (default: enabled)
|
40
|
-
--[no-]head - Include HEAD as a tag. Useful when new tag is not released yet (as a preview). Can be disabled. (default: enabled)
|
41
42
|
-o, --output=file - Output destination. (default: CHANGELOG.md)
|
42
|
-
|
43
|
-
|
43
|
+
|
44
|
+
|
45
|
+
## Customizing your changelog
|
46
|
+
All you need to do is to create a `.tag_changelog.yml` file in the root of the
|
47
|
+
git repository directory to override the default configuration from this gem.
|
48
|
+
|
49
|
+
Please take a look at the [default configuration yml file here](lib/tag_changelog/templates/config.yml) to learn more about the available options. You do not need to add all keys in your
|
50
|
+
custom `yml` file, only those you're interested in overriding.
|
data/bin/tag-changelog
CHANGED
@@ -11,58 +11,37 @@ require 'tag_changelog'
|
|
11
11
|
|
12
12
|
include GLI::App
|
13
13
|
|
14
|
-
program_desc 'Tool to generate changelog based on
|
14
|
+
program_desc 'Tool to generate changelog based on git commit history.'
|
15
15
|
|
16
16
|
version TagChangelog::VERSION
|
17
17
|
|
18
18
|
subcommand_option_handling :normal
|
19
19
|
arguments :strict
|
20
20
|
|
21
|
-
desc 'Generate changelog and write to
|
21
|
+
desc 'Generate changelog and write to markdown file. (default: CHANGELOG.md).'
|
22
22
|
command :generate do |c|
|
23
|
-
c.desc 'Configuration file to categorize commit messages in YML format. Must be an absolute path.'
|
24
|
-
c.default_value File.expand_path("../../lib/tag_changelog/templates/config.yml", __FILE__)
|
25
|
-
c.arg_name 'file'
|
26
|
-
c.flag [:c, :config]
|
27
|
-
|
28
23
|
c.desc 'Git repository directory (must be an absolute path). Defaults to working directory.'
|
29
24
|
c.default_value Dir.pwd
|
30
25
|
c.arg_name 'directory'
|
31
26
|
c.flag [:d, :dir]
|
32
27
|
|
33
28
|
c.desc 'Output destination.'
|
34
|
-
c.default_value 'CHANGELOG.md'
|
35
29
|
c.arg_name 'file'
|
36
30
|
c.flag [:o, :output]
|
37
31
|
|
38
|
-
c.
|
39
|
-
c.default_value '(\[+\s?+[cfbhrCFBHR]{1}+\s?+\])'
|
40
|
-
c.arg_name 'regexp'
|
41
|
-
c.flag [:f, :filter]
|
42
|
-
|
43
|
-
c.desc 'Skip tags'
|
44
|
-
c.arg_name 'tag_list'
|
45
|
-
c.flag [:s, :skip], multiple: true
|
46
|
-
|
47
|
-
c.desc 'Group commit messages in categories (defined in configuration file).'
|
48
|
-
c.default_value true
|
49
|
-
c.switch "group"
|
50
|
-
|
51
|
-
c.desc 'Include HEAD as a tag. Useful when new tag is not released yet (as a preview). Can be disabled.'
|
52
|
-
c.default_value true
|
53
|
-
c.switch "head"
|
54
|
-
|
55
|
-
c.desc 'Only list merged pull requests. Can be disabled to list all commits.'
|
56
|
-
c.default_value true
|
57
|
-
c.switch "pull-requests-only"
|
58
|
-
|
59
|
-
c.action do |global_options,options,args|
|
32
|
+
c.action do |global_options, options, args|
|
60
33
|
# Your command logic here
|
61
34
|
# If you have any errors, just raise them
|
62
35
|
# raise "that command made no sense"
|
36
|
+
config_file = File.expand_path("../../lib/tag_changelog/templates/config.yml", __FILE__)
|
63
37
|
Dir.chdir(options[:dir]) do
|
64
|
-
|
65
|
-
|
38
|
+
project_config = if File.exists?(".tag_changelog.yml")
|
39
|
+
YAML.load_file(File.open(".tag_changelog.yml"))
|
40
|
+
else
|
41
|
+
{}
|
42
|
+
end.merge("config_file" => config_file)
|
43
|
+
puts "Changelog will be written to: #{[options[:dir], project_config['output']].join('/')}"
|
44
|
+
TagChangelog::Generate.run(project_config, options)
|
66
45
|
end
|
67
46
|
end
|
68
47
|
end
|
data/lib/tag_changelog.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
# A class to manipulate output destination of changelog and to write its contents.
|
2
2
|
module TagChangelog
|
3
3
|
class Generate
|
4
|
-
def self.run(options)
|
5
|
-
new(options).run
|
4
|
+
def self.run(project_config, options)
|
5
|
+
new(project_config, options).run
|
6
6
|
end
|
7
7
|
|
8
|
-
def initialize(options = {})
|
8
|
+
def initialize(project_config = {}, options = {})
|
9
|
+
@project_config = project_config
|
9
10
|
@options = options
|
11
|
+
@config = build_configuration
|
10
12
|
@output = open_output_file
|
11
|
-
@tags_list = build_tags_list
|
12
|
-
@filter = Regexp.new(
|
13
|
-
@commit_messages_filter = set_commits_filter
|
14
|
-
@group =
|
13
|
+
@tags_list = build_tags_list
|
14
|
+
@filter = Regexp.new(config["filter"], true)
|
15
|
+
@commit_messages_filter = set_commits_filter
|
16
|
+
@group = config["group"]
|
15
17
|
end
|
16
18
|
|
17
19
|
def run
|
@@ -32,25 +34,36 @@ module TagChangelog
|
|
32
34
|
:tags_list,
|
33
35
|
:filter,
|
34
36
|
:commit_messages_filter,
|
35
|
-
:group
|
37
|
+
:group,
|
38
|
+
:config
|
39
|
+
|
40
|
+
def build_configuration
|
41
|
+
default_config
|
42
|
+
.merge(@project_config)
|
43
|
+
.merge(@options.delete_if { |_, v| v.nil? })
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_config
|
47
|
+
YAML.load_file(@project_config["config_file"])
|
48
|
+
end
|
36
49
|
|
37
50
|
def output_file_exists?
|
38
|
-
File.exists?(
|
51
|
+
File.exists?(config["output"])
|
39
52
|
end
|
40
53
|
|
41
54
|
def open_output_file
|
42
|
-
puts "#{
|
43
|
-
File.open(
|
55
|
+
puts "#{config['output']} doesn't exist in #{options[:dir]}... creating it" unless output_file_exists?
|
56
|
+
File.open(config["output"], "w+")
|
44
57
|
end
|
45
58
|
|
46
|
-
def build_tags_list
|
47
|
-
Git::TagList.new(
|
48
|
-
tag if
|
59
|
+
def build_tags_list
|
60
|
+
Git::TagList.new(config["head"]).list.reject do |tag|
|
61
|
+
tag if config["skip"].include?(tag)
|
49
62
|
end
|
50
63
|
end
|
51
64
|
|
52
|
-
def set_commits_filter
|
53
|
-
|
65
|
+
def set_commits_filter
|
66
|
+
config["pull-requests-only"] ? 'Merge pull request' : nil
|
54
67
|
end
|
55
68
|
|
56
69
|
def get_commit_messages(previous_tag, current_tag)
|
@@ -58,8 +71,8 @@ module TagChangelog
|
|
58
71
|
current_tag,
|
59
72
|
commit_messages_filter).split("\n")
|
60
73
|
# if not filtering merged pull requests only
|
61
|
-
# we need to remove the commit
|
62
|
-
messages = messages.map { |msg| msg[
|
74
|
+
# we need to remove the commit sha1
|
75
|
+
messages = messages.map { |msg| msg.split(" ")[1..-1].join(" ") } unless commit_messages_filter
|
63
76
|
messages = categorize_messages(messages, build_categories) if group
|
64
77
|
messages = MessageList.new(messages, group)
|
65
78
|
end
|
@@ -75,7 +88,7 @@ module TagChangelog
|
|
75
88
|
msg = msg.gsub!(filter, matching_category["bullet"])
|
76
89
|
matching_category["messages"].push(msg)
|
77
90
|
else
|
78
|
-
uncategorized["messages"].push("
|
91
|
+
uncategorized["messages"].push("#{msg}")
|
79
92
|
end
|
80
93
|
end
|
81
94
|
|
@@ -83,39 +96,10 @@ module TagChangelog
|
|
83
96
|
end
|
84
97
|
|
85
98
|
def build_categories
|
86
|
-
categories =
|
99
|
+
categories = config["categories"].dup
|
100
|
+
categories.push({ "bullet" => "[U]", "header" => "Uncategorized" })
|
87
101
|
categories.each { |category| category["messages"] = [] }
|
88
102
|
categories
|
89
103
|
end
|
90
|
-
|
91
|
-
class MessageList
|
92
|
-
attr_reader :messages, :grouped
|
93
|
-
|
94
|
-
def initialize(messages = [], grouped = true)
|
95
|
-
@messages = messages
|
96
|
-
@grouped = grouped
|
97
|
-
end
|
98
|
-
|
99
|
-
def to_text
|
100
|
-
if grouped
|
101
|
-
messages.map do |category|
|
102
|
-
category["messages"].any? ? print_category(category) : nil
|
103
|
-
end.reject(&:nil?).join("")
|
104
|
-
else
|
105
|
-
print_lines(messages).reject(&:nil?).join("")
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def print_category(category)
|
110
|
-
[
|
111
|
-
"#### #{category['header']}",
|
112
|
-
print_lines(category["messages"]).join(""),
|
113
|
-
].join("\n")
|
114
|
-
end
|
115
|
-
|
116
|
-
def print_lines(lines)
|
117
|
-
lines.map { |line| "#{line}\n" }
|
118
|
-
end
|
119
|
-
end
|
120
104
|
end
|
121
105
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module TagChangelog
|
2
|
+
class MessageList
|
3
|
+
attr_reader :messages, :grouped
|
4
|
+
|
5
|
+
def initialize(messages = [], grouped = true)
|
6
|
+
@messages = messages
|
7
|
+
@grouped = grouped
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_text
|
11
|
+
if grouped
|
12
|
+
messages.map do |category|
|
13
|
+
category["messages"].any? ? print_category(category) : nil
|
14
|
+
end.reject(&:nil?).join("")
|
15
|
+
else
|
16
|
+
print_lines(messages).reject(&:nil?).join("")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def print_category(category)
|
21
|
+
[
|
22
|
+
"#### #{category['header']}",
|
23
|
+
print_lines(category["messages"]).join(""),
|
24
|
+
].join("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_lines(lines)
|
28
|
+
lines.map { |line| "* #{line}\n" }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,37 +1,59 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
1
|
+
filter: '(\[+\s?+[cfbhrCFBHR]{1}+\s?+\])'
|
2
|
+
# Group commit messages in categories
|
3
|
+
# (default: enabled)
|
4
|
+
group: true
|
5
|
+
# Include HEAD as a tag.
|
6
|
+
# Useful when new tag is not released yet (as a preview).
|
7
|
+
# (default: enabled)
|
8
|
+
head: true
|
9
|
+
# Output destination.
|
10
|
+
output: CHANGELOG.md
|
11
|
+
# Only list merged pull requests.
|
12
|
+
# Can be disabled to list all commits.
|
13
|
+
# (default: enabled)
|
14
|
+
"pull-requests-only": true
|
15
|
+
# Skip tags.
|
16
|
+
# Add tag names not to list in the changelog output.
|
17
|
+
skip:
|
18
|
+
-
|
19
|
+
# How to categorize/group commit messages.
|
20
|
+
# An entry must include: :bullet, :header and can optionally include :filters
|
21
|
+
# :bullet String to add to commit message
|
22
|
+
# :header String used as header to list all matching messages
|
23
|
+
# :filters Array of Strings used to match agains commit messages
|
24
|
+
categories:
|
25
|
+
- bullet: "[F]"
|
26
|
+
filters:
|
27
|
+
- "[F]"
|
28
|
+
- "[ F ]"
|
29
|
+
- "[f]"
|
30
|
+
- "[ f ]"
|
31
|
+
header: "Features"
|
32
|
+
- bullet: "[C]"
|
33
|
+
filters:
|
34
|
+
- "[C]"
|
35
|
+
- "[ C ]"
|
36
|
+
- "[c]"
|
37
|
+
- "[ c ]"
|
38
|
+
header: "Configuration"
|
39
|
+
- bullet: "[B]"
|
40
|
+
filters:
|
41
|
+
- "[B]"
|
42
|
+
- "[ B ]"
|
43
|
+
- "[b]"
|
44
|
+
- "[ b ]"
|
45
|
+
header: "Bug Fixes"
|
46
|
+
- bullet: "[H]"
|
47
|
+
filters:
|
48
|
+
- "[H]"
|
49
|
+
- "[ H ]"
|
50
|
+
- "[h]"
|
51
|
+
- "[ h ]"
|
52
|
+
header: "Hotfixes"
|
53
|
+
- bullet: "[R]"
|
54
|
+
filters:
|
55
|
+
- "[R]"
|
56
|
+
- "[ R ]"
|
57
|
+
- "[r]"
|
58
|
+
- "[ r ]"
|
59
|
+
header: "Refactored"
|
data/tag-changelog.gemspec
CHANGED
@@ -6,7 +6,7 @@ spec = Gem::Specification.new do |s|
|
|
6
6
|
s.license = 'MIT'
|
7
7
|
s.author = 'Parallel6'
|
8
8
|
s.email = 'contact@parallel6.com'
|
9
|
-
s.homepage = '
|
9
|
+
s.homepage = 'https://github.com/parallel-6/tag-changelog'
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.summary = 'Tool to generate changelog based on Parallel6 specs'
|
12
12
|
s.files = `git ls-files`.split("
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tag-changelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parallel6
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -101,12 +101,13 @@ files:
|
|
101
101
|
- lib/tag_changelog/git/git.rb
|
102
102
|
- lib/tag_changelog/git/tag.rb
|
103
103
|
- lib/tag_changelog/git/tag_list.rb
|
104
|
+
- lib/tag_changelog/message_list.rb
|
104
105
|
- lib/tag_changelog/templates/config.yml
|
105
106
|
- lib/tag_changelog/version.rb
|
106
107
|
- tag-changelog.gemspec
|
107
108
|
- test/default_test.rb
|
108
109
|
- test/test_helper.rb
|
109
|
-
homepage:
|
110
|
+
homepage: https://github.com/parallel-6/tag-changelog
|
110
111
|
licenses:
|
111
112
|
- MIT
|
112
113
|
metadata: {}
|