github_changelog_generator 1.10.1 → 1.10.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,23 @@
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
1
3
  require "rubocop/rake_task"
2
4
  require "rspec/core/rake_task"
5
+ require "pathname"
6
+ require "fileutils"
7
+ require "overcommit"
3
8
 
4
9
  RuboCop::RakeTask.new
5
10
  RSpec::Core::RakeTask.new(:rspec)
6
11
 
7
- task default: [:rubocop, :rspec]
12
+ task :create_man do |_t|
13
+ os_prefix = "/usr/local"
14
+ man_prefix = Pathname("#{os_prefix}/share/man/man1")
15
+ man_pages = "man/git-*"
16
+
17
+ Pathname.glob(man_pages) do |path|
18
+ FileUtils.cp(path, man_prefix + path.basename)
19
+ end
20
+ end
21
+
22
+ task checks: [:rubocop, :rspec]
23
+ task default: [:checks, :create_man]
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require_relative "../lib/github_changelog_generator"
4
+ GitHubChangelogGenerator::ChangelogGenerator.new.run
@@ -17,16 +17,16 @@ Gem::Specification.new do |spec|
17
17
  spec.description = "Changelog generation has never been so easy. Fully automate changelog generation - this gem generate change log file based on tags, issues and merged pull requests from Github issue tracker."
18
18
  spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator"
19
19
  spec.license = "MIT"
20
+ spec.extensions = ["Rakefile"]
20
21
 
21
22
  spec.files = `git ls-files -z`.split("\x0")
22
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
25
  spec.require_paths = ["lib"]
25
26
 
27
+ spec.add_runtime_dependency "rake", "~> 10.0"
28
+ spec.add_runtime_dependency "bundler", "~> 1.7"
26
29
  spec.add_runtime_dependency("github_api", ["~> 0.12"])
27
30
  spec.add_runtime_dependency("colorize", ["~> 0.7"])
28
-
29
- # Development only
30
- spec.add_development_dependency "bundler", "~> 1.7"
31
- spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_runtime_dependency("overcommit", "~>0.31")
32
32
  end
@@ -28,7 +28,7 @@ module GitHubChangelogGenerator
28
28
  def run
29
29
  log = @generator.compound_changelog
30
30
 
31
- output_filename = "#{@options[:output]}"
31
+ output_filename = (@options[:output]).to_s
32
32
  File.open(output_filename, "w") { |file| file.write(log) }
33
33
  puts "Done!"
34
34
  puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
@@ -123,16 +123,16 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
123
123
  def fetch_closed_pull_requests
124
124
  pull_requests = []
125
125
  begin
126
- if @options[:release_branch].nil?
127
- response = @github.pull_requests.list @options[:user],
126
+ response = if @options[:release_branch].nil?
127
+ @github.pull_requests.list @options[:user],
128
128
  @options[:project],
129
129
  state: "closed"
130
- else
131
- response = @github.pull_requests.list @options[:user],
130
+ else
131
+ @github.pull_requests.list @options[:user],
132
132
  @options[:project],
133
133
  state: "closed",
134
134
  base: @options[:release_branch]
135
- end
135
+ end
136
136
  page_i = 0
137
137
  count_pages = response.count_pages
138
138
  response.each_page do |page|
@@ -8,13 +8,15 @@ module GitHubChangelogGenerator
8
8
  sort_tags_by_date(@filtered_tags)
9
9
  fetch_issues_and_pr
10
10
 
11
- log = "#{@options[:header]}\n\n"
11
+ log = ""
12
+ log += @options[:frontmatter] if @options[:frontmatter]
13
+ log += "#{@options[:header]}\n\n"
12
14
 
13
- if @options[:unreleased_only]
14
- log += generate_log_between_tags(filtered_tags[0], nil)
15
- else
16
- log += generate_log_for_all_tags
17
- end
15
+ log += if @options[:unreleased_only]
16
+ generate_log_between_tags(filtered_tags[0], nil)
17
+ else
18
+ generate_log_for_all_tags
19
+ end
18
20
 
19
21
  log += File.read(@options[:base]) if File.file?(@options[:base])
20
22
 
@@ -37,10 +39,10 @@ module GitHubChangelogGenerator
37
39
  index2 = hash[tag2]
38
40
  log += generate_log_between_tags(all_tags[index1], all_tags[index2])
39
41
  else
40
- fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
42
+ raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
41
43
  end
42
44
  else
43
- fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
45
+ raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
44
46
  end
45
47
  log
46
48
  end
@@ -77,16 +79,16 @@ module GitHubChangelogGenerator
77
79
  time_string = newer_tag_time.strftime @options[:date_format]
78
80
 
79
81
  # Generate tag name and link
80
- if @options[:release_url]
81
- release_url = format(@options[:release_url], newer_tag_link)
82
- else
83
- release_url = "#{project_url}/tree/#{newer_tag_link}"
84
- end
85
- if newer_tag_name.equal? @options[:unreleased_label]
86
- log += "## [#{newer_tag_name}](#{release_url})\n\n"
87
- else
88
- log += "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n"
89
- end
82
+ release_url = if @options[:release_url]
83
+ format(@options[:release_url], newer_tag_link)
84
+ else
85
+ "#{project_url}/tree/#{newer_tag_link}"
86
+ end
87
+ log += if newer_tag_name.equal? @options[:unreleased_label]
88
+ "## [#{newer_tag_name}](#{release_url})\n\n"
89
+ else
90
+ "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n"
91
+ end
90
92
 
91
93
  if @options[:compare_link] && older_tag_link
92
94
  # Generate compare link
@@ -169,11 +171,11 @@ module GitHubChangelogGenerator
169
171
 
170
172
  unless issue.pull_request.nil?
171
173
  if @options[:author]
172
- if issue.user.nil?
173
- title_with_number += " ({Null user})"
174
- else
175
- title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))"
176
- end
174
+ title_with_number += if issue.user.nil?
175
+ " ({Null user})"
176
+ else
177
+ " ([#{issue.user.login}](#{issue.user.html_url}))"
178
+ end
177
179
  end
178
180
  end
179
181
  title_with_number
@@ -7,7 +7,7 @@ module GitHubChangelogGenerator
7
7
  unless @options[:exclude_labels].nil?
8
8
  issues = issues.select do |issue|
9
9
  var = issue.labels.map(&:name) & @options[:exclude_labels]
10
- !(var).any?
10
+ !var.any?
11
11
  end
12
12
  end
13
13
  issues
@@ -83,7 +83,7 @@ module GitHubChangelogGenerator
83
83
 
84
84
  tag_in_range_new = tag_older_new_tag?(newer_tag_time, time)
85
85
 
86
- tag_in_range = (tag_in_range_old) && (tag_in_range_new)
86
+ tag_in_range = tag_in_range_old && tag_in_range_new
87
87
 
88
88
  tag_in_range
89
89
  else
@@ -93,20 +93,20 @@ module GitHubChangelogGenerator
93
93
  end
94
94
 
95
95
  def tag_older_new_tag?(newer_tag_time, time)
96
- if newer_tag_time.nil?
97
- tag_in_range_new = true
98
- else
99
- tag_in_range_new = time <= newer_tag_time
100
- end
96
+ tag_in_range_new = if newer_tag_time.nil?
97
+ true
98
+ else
99
+ time <= newer_tag_time
100
+ end
101
101
  tag_in_range_new
102
102
  end
103
103
 
104
104
  def tag_newer_old_tag?(older_tag_time, t)
105
- if older_tag_time.nil?
106
- tag_in_range_old = true
107
- else
108
- tag_in_range_old = t > older_tag_time
109
- end
105
+ tag_in_range_old = if older_tag_time.nil?
106
+ true
107
+ else
108
+ t > older_tag_time
109
+ end
110
110
  tag_in_range_old
111
111
  end
112
112
 
@@ -133,7 +133,7 @@ module GitHubChangelogGenerator
133
133
  def filter_by_include_labels(issues)
134
134
  filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue|
135
135
  labels = issue.labels.map(&:name) & @options[:include_labels]
136
- (labels).any?
136
+ labels.any?
137
137
  end
138
138
  filtered_issues
139
139
  end
@@ -19,7 +19,7 @@ module GitHubChangelogGenerator
19
19
  # @param [Hash] tag_name name of the tag
20
20
  # @return [Time] time of specified tag
21
21
  def get_time_of_tag(tag_name)
22
- fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
22
+ raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
23
23
 
24
24
  name_of_tag = tag_name["name"]
25
25
  time_for_name = @tag_times_hash[name_of_tag]
@@ -58,7 +58,7 @@ module GitHubChangelogGenerator
58
58
  if @since_tag.nil? && @options[:base] && File.file?(@options[:base])
59
59
  reader = GitHubChangelogGenerator::Reader.new
60
60
  content = reader.read(@options[:base])
61
- @since_tag = content[0]["version"] if content
61
+ @since_tag = content[0]["version"] if content.count && content
62
62
  end
63
63
  @since_tag
64
64
  end
@@ -80,11 +80,11 @@ module GitHubChangelogGenerator
80
80
  if tag
81
81
  if all_tags.map(&:name).include? tag
82
82
  idx = all_tags.index { |t| t.name == tag }
83
- if idx > 0
84
- filtered_tags = all_tags[0..idx - 1]
85
- else
86
- filtered_tags = []
87
- end
83
+ filtered_tags = if idx > 0
84
+ all_tags[0..idx - 1]
85
+ else
86
+ []
87
+ end
88
88
  else
89
89
  Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option."
90
90
  end
@@ -101,11 +101,11 @@ module GitHubChangelogGenerator
101
101
  if (all_tags.count > 0) && (all_tags.map(&:name).include? tag)
102
102
  idx = all_tags.index { |t| t.name == tag }
103
103
  last_index = all_tags.count - 1
104
- if idx > 0 && idx < last_index
105
- filtered_tags = all_tags[idx + 1..last_index]
106
- else
107
- filtered_tags = []
108
- end
104
+ filtered_tags = if idx > 0 && idx < last_index
105
+ all_tags[idx + 1..last_index]
106
+ else
107
+ []
108
+ end
109
109
  else
110
110
  Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option."
111
111
  end
@@ -3,14 +3,14 @@ module GitHubChangelogGenerator
3
3
  module Helper
4
4
  # @return true if the currently running program is a unit test
5
5
  def self.test?
6
- defined?SpecHelper
6
+ defined? SpecHelper
7
7
  end
8
8
 
9
- if test?
10
- @log ||= Logger.new(nil) # don't show any logs when running tests
11
- else
12
- @log ||= Logger.new(STDOUT)
13
- end
9
+ @log ||= if test?
10
+ Logger.new(nil) # don't show any logs when running tests
11
+ else
12
+ Logger.new(STDOUT)
13
+ end
14
14
  @log.formatter = proc do |severity, _datetime, _progname, msg|
15
15
  string = "#{msg}\n"
16
16
 
@@ -68,6 +68,9 @@ module GitHubChangelogGenerator
68
68
  opts.on("--header-label [LABEL]", "Setup custom header label. Default is \"# Change Log\"") do |v|
69
69
  options[:header] = v
70
70
  end
71
+ opts.on("--front-matter [JSON]", "Add YAML front matter. Formatted as JSON because it's easier to add on the command line") do |v|
72
+ options[:frontmatter] = JSON.parse(v).to_yaml + "---\n"
73
+ end
71
74
  opts.on("--pr-label [LABEL]", "Setup custom label for pull requests section. Default is \"**Merged pull requests:**\"") do |v|
72
75
  options[:merge_prefix] = v
73
76
  end
@@ -20,8 +20,8 @@ module GitHubChangelogGenerator
20
20
 
21
21
  def parse_line!(line)
22
22
  key_sym, value = extract_pair(line)
23
- value = true if value =~ (/^(true|t|yes|y|1)$/i)
24
- value = false if value =~ (/^(false|f|no|n|0)$/i)
23
+ value = true if value =~ /^(true|t|yes|y|1)$/i
24
+ value = false if value =~ /^(false|f|no|n|0)$/i
25
25
  @options[key_sym] = value
26
26
  rescue
27
27
  raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""
@@ -37,7 +37,7 @@ module GitHubChangelogGenerator
37
37
  def define(args, &task_block)
38
38
  desc "Generate a Change log from GitHub"
39
39
 
40
- task_block.call(*[self, args].slice(0, task_block.arity)) if task_block
40
+ yield(*[self, args].slice(0, task_block.arity)) if task_block
41
41
 
42
42
  # clear any (auto-)pre-existing task
43
43
  Rake::Task[@name].clear if Rake::Task.task_defined?(@name)
@@ -57,7 +57,7 @@ module GitHubChangelogGenerator
57
57
 
58
58
  log = generator.compound_changelog
59
59
 
60
- output_filename = "#{options[:output]}"
60
+ output_filename = (options[:output]).to_s
61
61
  File.open(output_filename, "w") { |file| file.write(log) }
62
62
  puts "Done!"
63
63
  puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
@@ -1,3 +1,3 @@
1
1
  module GitHubChangelogGenerator
2
- VERSION = "1.10.1"
2
+ VERSION = "1.10.4"
3
3
  end
@@ -0,0 +1,252 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "GIT\-GENERATE\-CHANGELOG" "1" "October 2015" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBgit\-generate\-changelog\fR \- Generate changelog from github
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBgit generate\-changelog\fR [\-h|\-\-help] [\-u|\-\-user] [\-p|\-\-project]
11
+ .
12
+ .SH "DESCRIPTION"
13
+ Automatically generate change log from your tags, issues, labels and pull requests on GitHub\.
14
+ .
15
+ .SH "OPTIONS"
16
+ \-u, \-\-user [USER]
17
+ .
18
+ .P
19
+ Username of the owner of target GitHub repo
20
+ .
21
+ .P
22
+ \-p, \-\-project [PROJECT]
23
+ .
24
+ .P
25
+ Name of project on GitHub
26
+ .
27
+ .P
28
+ \-t, \-\-token [TOKEN]
29
+ .
30
+ .P
31
+ To make more than 50 requests per hour your GitHub token is required\. You can generate it at: https://github\.com/settings/tokens/new
32
+ .
33
+ .P
34
+ \-f, \-\-date\-format [FORMAT]
35
+ .
36
+ .P
37
+ Date format\. Default is %Y\-%m\-%d
38
+ .
39
+ .P
40
+ \-o, \-\-output [NAME]
41
+ .
42
+ .P
43
+ Output file\. Default is CHANGELOG\.md
44
+ .
45
+ .P
46
+ \-b, \-\-base [NAME]
47
+ .
48
+ .P
49
+ Optional base file to append generated changes to\.
50
+ .
51
+ .P
52
+ \-\-bugs\-label [LABEL]
53
+ .
54
+ .P
55
+ Setup custom label for bug\-fixes section\. Default is "\fBFixed bugs:\fR
56
+ .
57
+ .P
58
+ \-\-enhancement\-label [LABEL]
59
+ .
60
+ .P
61
+ Setup custom label for enhancements section\. Default is "\fBImplemented enhancements:\fR"
62
+ .
63
+ .P
64
+ \-\-issues\-label [LABEL]
65
+ .
66
+ .P
67
+ Setup custom label for closed\-issues section\. Default is "\fBClosed issues:\fR"
68
+ .
69
+ .P
70
+ \-\-header\-label [LABEL]
71
+ .
72
+ .P
73
+ Setup custom header label\. Default is "# Change Log"
74
+ .
75
+ .P
76
+ \-\-pr\-label [LABEL]
77
+ .
78
+ .P
79
+ Setup custom label for pull requests section\. Default is "\fBMerged pull requests:\fR"
80
+ .
81
+ .P
82
+ \-\-[no\-]issues
83
+ .
84
+ .P
85
+ Include closed issues in changelog\. Default is true
86
+ .
87
+ .P
88
+ \-\-[no\-]issues\-wo\-labels
89
+ .
90
+ .P
91
+ Include closed issues without labels in changelog\. Default is true
92
+ .
93
+ .P
94
+ \-\-[no\-]pr\-wo\-labels
95
+ .
96
+ .P
97
+ Include pull requests without labels in changelog\. Default is true
98
+ .
99
+ .P
100
+ \-\-[no\-]pull\-requests
101
+ .
102
+ .P
103
+ Include pull\-requests in changelog\. Default is true
104
+ .
105
+ .P
106
+ \-\-[no\-]filter\-by\-milestone
107
+ .
108
+ .P
109
+ Use milestone to detect when issue was resolved\. Default is true
110
+ .
111
+ .P
112
+ \-\-[no\-]author
113
+ .
114
+ .P
115
+ Add author of pull\-request in the end\. Default is true
116
+ .
117
+ .P
118
+ \-\-unreleased\-only
119
+ .
120
+ .P
121
+ Generate log from unreleased closed issues only\.
122
+ .
123
+ .P
124
+ \-\-[no\-]unreleased
125
+ .
126
+ .P
127
+ Add to log unreleased closed issues\. Default is true
128
+ .
129
+ .P
130
+ \-\-unreleased\-label [label]
131
+ .
132
+ .P
133
+ Add to log unreleased closed issues\. Default is true
134
+ .
135
+ .P
136
+ \-\-[no\-]compare\-link
137
+ .
138
+ .P
139
+ Include compare link (Full Changelog) between older version and newer version\. Default is true
140
+ .
141
+ .P
142
+ \-\-include\-labels x,y,z
143
+ .
144
+ .P
145
+ Only issues with the specified labels will be included in the changelog\.
146
+ .
147
+ .P
148
+ \-\-exclude\-labels x,y,z
149
+ .
150
+ .P
151
+ Issues with the specified labels will be always excluded from changelog\. Default is \'duplicate,question,invalid,wontfix\'
152
+ .
153
+ .P
154
+ \-\-bug\-labels x,y,z
155
+ .
156
+ .P
157
+ Issues with the specified labels will be always added to "Fixed bugs" section\. Default is \'bug,Bug\'
158
+ .
159
+ .P
160
+ \-\-enhancement\-labels x,y,z
161
+ .
162
+ .P
163
+ Issues with the specified labels will be always added to "Implemented enhancements" section\. Default is \'enhancement,Enhancement\'
164
+ .
165
+ .P
166
+ \-\-between\-tags x,y,z
167
+ .
168
+ .P
169
+ Change log will be filled only between specified tags
170
+ .
171
+ .P
172
+ \-\-exclude\-tags x,y,z
173
+ .
174
+ .P
175
+ Change log will exclude specified tags
176
+ .
177
+ .P
178
+ \-\-since\-tag x
179
+ .
180
+ .P
181
+ Change log will start after specified tag
182
+ .
183
+ .P
184
+ \-\-due\-tag x
185
+ .
186
+ .P
187
+ Change log will end before specified tag
188
+ .
189
+ .P
190
+ \-\-max\-issues [NUMBER]
191
+ .
192
+ .P
193
+ Max number of issues to fetch from GitHub\. Default is unlimited
194
+ .
195
+ .P
196
+ \-\-release\-url [URL]
197
+ .
198
+ .P
199
+ The URL to point to for release links, in printf format (with the tag as variable)\.
200
+ .
201
+ .P
202
+ \-\-github\-site [URL]
203
+ .
204
+ .P
205
+ The Enterprise Github site on which your project is hosted\.
206
+ .
207
+ .P
208
+ \-\-github\-api [URL]
209
+ .
210
+ .P
211
+ The enterprise endpoint to use for your Github API\.
212
+ .
213
+ .P
214
+ \-\-simple\-list
215
+ .
216
+ .P
217
+ Create simple list from issues and pull requests\. Default is false\.
218
+ .
219
+ .P
220
+ \-\-future\-release [RELEASE\-VERSION]
221
+ .
222
+ .P
223
+ Put the unreleased changes in the specified release number\.
224
+ .
225
+ .P
226
+ \-\-[no\-]verbose
227
+ .
228
+ .P
229
+ Run verbosely\. Default is true
230
+ .
231
+ .P
232
+ \-v, \-\-version
233
+ .
234
+ .P
235
+ Print version number
236
+ .
237
+ .P
238
+ \-h, \-\-help
239
+ .
240
+ .P
241
+ Displays Help
242
+ .
243
+ .SH "EXAMPLES"
244
+ .
245
+ .SH "AUTHOR"
246
+ Written by Petr Korolev sky4winder@gmail\.com
247
+ .
248
+ .SH "REPORTING BUGS"
249
+ <\fIhttps://github\.com/skywinder/github\-changelog\-generator/issues\fR>
250
+ .
251
+ .SH "SEE ALSO"
252
+ <\fIhttps://github\.com/skywinder/github\-changelog\-generator/\fR>