tag-changelog 0.1.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9293d2c322efcd8fb7411c8bcb7c47d161b7a985
4
- data.tar.gz: 1569037ac2782b2b24564335f6e0515f52dce1d6
3
+ metadata.gz: 3b55176897ce91e86571753da01176a5b0e74cee
4
+ data.tar.gz: aaaa4cdd9e1d79e2d0090f79947286a7f72d12c5
5
5
  SHA512:
6
- metadata.gz: 364e78e00b586099fe42fb690fd0968ac0c56de31cf417d13ee07308f8619e3eeb57d20598eb1b3cad49a9f9a6dbe66b8d42f2a066b1eb032ad879bba2a581b9
7
- data.tar.gz: 5ef46f7c023d99bdafc4598313782aeaf0d36cda7afd731424af110d8d28312a21ec3e7bec451f639df1c391a9f66af67ef04a8d53c9eaa4f7df7aada613a2ae
6
+ metadata.gz: 7f8c35d82d4109700b0216509febed7f6d27100dd5bfb605b5c8638aa389e3a49a7336c4fdd618bd6d7d6f470121efd9e530c4824574ac76ccf70a1e6bba0175
7
+ data.tar.gz: c5526369f596e8aeecec098a97ff03ce899989199527d1ae29e54880b969b9060085ee426c5a66ef18588e66afe6161af9de153c943f298d2496c9f61c85d242
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
- = changelog
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tag-changelog (0.1.0)
4
+ tag-changelog (1.0.0)
5
5
  gli (= 2.17.1)
6
6
 
7
7
  GEM
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 Parallel6 specs
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.1
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. Please see below
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
- --[no-]pull-requests-only - Only list merged pull requests. Can be disabled to list all commits. (default: enabled)
43
- -s, --skip=tag_list - Skip tags (may be used more than once, default: none)
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 Parallel6 specs'
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 CHANGELOG.md (default).'
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.desc 'Regexp to categorize commits from git log.'
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
- puts "Changelog will be written to: #{[options[:dir], options[:output]].join('/')}"
65
- TagChangelog::Generate.run(options)
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
@@ -6,4 +6,5 @@ require 'tag_changelog/version'
6
6
  require 'tag_changelog/git/git'
7
7
  require 'tag_changelog/git/tag_list'
8
8
  require 'tag_changelog/git/tag'
9
+ require 'tag_changelog/message_list'
9
10
  require 'tag_changelog/generate'
@@ -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(options)
12
- @filter = Regexp.new(options[:filter], true)
13
- @commit_messages_filter = set_commits_filter(options)
14
- @group = options[: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?(options[:output])
51
+ File.exists?(config["output"])
39
52
  end
40
53
 
41
54
  def open_output_file
42
- puts "#{options[:output]} doesn't exist in #{options[:dir]}... creating it" unless output_file_exists?
43
- File.open(options[:output], "w+")
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(options)
47
- Git::TagList.new(options[:head]).list.reject do |tag|
48
- tag if options[:skip].include?(tag)
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(options)
53
- options["pull-requests-only"] ? 'Merge pull request' : nil
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 sha (first 9 chars in each row)
62
- messages = messages.map { |msg| msg[10..-1] } unless commit_messages_filter
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("* #{msg}")
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 = YAML.load_file(options[:config])
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
- - bullet: "[F]"
2
- filters:
3
- - "[F]"
4
- - "[ F ]"
5
- - "[f]"
6
- - "[ f ]"
7
- header: "Features"
8
- - bullet: "[C]"
9
- filters:
10
- - "[C]"
11
- - "[ C ]"
12
- - "[c]"
13
- - "[ c ]"
14
- header: "Configuration"
15
- - bullet: "[B]"
16
- filters:
17
- - "[B]"
18
- - "[ B ]"
19
- - "[b]"
20
- - "[ b ]"
21
- header: "Bug Fixes"
22
- - bullet: "[H]"
23
- filters:
24
- - "[H]"
25
- - "[ H ]"
26
- - "[h]"
27
- - "[ h ]"
28
- header: "Hotfixes"
29
- - bullet: "[R]"
30
- filters:
31
- - "[R]"
32
- - "[ R ]"
33
- - "[r]"
34
- - "[ r ]"
35
- header: "Refactored"
36
- - bullet: "[U]"
37
- header: "Uncategorized"
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"
@@ -1,3 +1,3 @@
1
1
  module TagChangelog
2
- VERSION = '0.1.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -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 = 'http://clinical6.com'
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: 0.1.0
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-02-23 00:00:00.000000000 Z
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: http://clinical6.com
110
+ homepage: https://github.com/parallel-6/tag-changelog
110
111
  licenses:
111
112
  - MIT
112
113
  metadata: {}