github_changelog_generator 1.1.0 → 1.1.1

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: 5f83cc895379430ee9e8613e77a63a10cec53de4
4
- data.tar.gz: 59190fee38e70eff912d176f67b8facb5e8cf9ad
3
+ metadata.gz: 2910060704d47726210ebc0f351fea2ff65b817e
4
+ data.tar.gz: 8bbeb1926718b2474d9f020f5ae4aa69f86e5737
5
5
  SHA512:
6
- metadata.gz: f0e1137eacbd273a7e2aa5b90a1e8070d84c5634df249efc40e218a99967c59b05547ad03d6803ff60bc0b408d08b3915fb25138522d4952f5cf9922799ebc33
7
- data.tar.gz: 8f5a48ede2c1f7863dabe0cf3a70eda72a1e6cd721f54bc3d157715c217682bbee8a2dc041078c60836e0815e868476ba9c3616433a545ac4250b7b5149f207b
6
+ metadata.gz: 1962c167ec181d5894e915c3aa51e6db2642777fcdd783f9ac3dfc50bdf5e15412238ef56eb32028610b05de04e5ee7f03e1a88a650c4177f4ba842343326bdf
7
+ data.tar.gz: ed77434e26d4702ce68d2948fece33371b3e7f02d6645c94c74e893f8aa4be80e2ac5de2f7d89c96bcdc8f09ad16255265ce7c6a7401e92ff194fac8fdca9e98
@@ -80,12 +80,7 @@ class ChangelogGenerator
80
80
  log += self.generate_log_for_all_tags
81
81
  end
82
82
 
83
-
84
- if @options[:verbose]
85
- puts log
86
- end
87
-
88
- log += "\n\n* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
83
+ log += "\n\n\\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
89
84
 
90
85
  output_filename = "#{@options[:output]}"
91
86
  File.open(output_filename, 'w') { |file| file.write(log) }
@@ -228,7 +223,7 @@ class ChangelogGenerator
228
223
  # Generate pull requests:
229
224
  if pull_requests
230
225
  pull_requests.each { |dict|
231
- merge = "#{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/pull/#{dict[:number]})\n\n"
226
+ merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
232
227
  log += "- #{merge}"
233
228
  }
234
229
  end
@@ -237,34 +232,47 @@ class ChangelogGenerator
237
232
  if @options[:issues]
238
233
  # Generate issues:
239
234
  if issues
240
- issues.each { |dict|
241
- is_bug = false
242
- is_enhancement = false
243
- dict.labels.each { |label|
244
- if label.name == 'bug'
245
- is_bug = true
246
- end
247
- if label.name == 'enhancement'
248
- is_enhancement = true
235
+ issues.sort! { |x, y|
236
+ if x.labels.any? && y.labels.any?
237
+ x.labels[0].name <=> y.labels[0].name
238
+ else
239
+ if x.labels.any?
240
+ 1
241
+ else
242
+ if y.labels.any?
243
+ -1
244
+ else
245
+ 0
246
+ end
249
247
  end
250
- }
251
-
252
- intro = 'Closed issue'
253
- if is_bug
254
- intro = 'Fixed bug'
255
248
  end
256
-
257
- if is_enhancement
258
- intro = 'Implemented enhancement'
249
+ }.reverse!
250
+ end
251
+ issues.each { |dict|
252
+ is_bug = false
253
+ is_enhancement = false
254
+ dict.labels.each { |label|
255
+ if label.name == 'bug'
256
+ is_bug = true
257
+ end
258
+ if label.name == 'enhancement'
259
+ is_enhancement = true
259
260
  end
260
-
261
- merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/issues/#{dict[:number]})\n\n"
262
- log += "- #{merge}"
263
261
  }
264
- end
265
262
 
266
- end
263
+ intro = 'Closed issue'
264
+ if is_bug
265
+ intro = 'Fixed bug'
266
+ end
267
+
268
+ if is_enhancement
269
+ intro = 'Implemented enhancement'
270
+ end
267
271
 
272
+ merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
273
+ log += "- #{merge}"
274
+ }
275
+ end
268
276
  log
269
277
  end
270
278
 
@@ -286,15 +294,31 @@ class ChangelogGenerator
286
294
 
287
295
  def get_all_issues
288
296
  all_issues = []
289
- @options[:labels].each { |label|
290
- issues = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: label
291
- all_issues = all_issues.concat(issues.body)
297
+
298
+ issues_req = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
299
+
300
+ filtered_issues = issues_req.body.select { |issues|
301
+ #compare is there any labels from @options[:labels] array
302
+ (issues.labels.map { |issue| issue.name } & @options[:labels]).any?
303
+ }
304
+
305
+ if @options[:add_issues_wo_labels]
306
+ issues_wo_labels = issues_req.body.select {
307
+ |issues| !issues.labels.map { |issue| issue.name }.any?
308
+ }
309
+ filtered_issues.concat(issues_wo_labels)
310
+ end
311
+
312
+ # remove pull request from issues:
313
+ filtered_issues.select! { |x|
314
+ x.pull_request == nil
292
315
  }
316
+
293
317
  if @options[:verbose]
294
318
  puts "Receive all closed issues with labels #{@options[:labels]}: #{all_issues.count} issues"
295
319
  end
296
320
 
297
- all_issues
321
+ filtered_issues
298
322
 
299
323
  end
300
324
 
@@ -3,7 +3,7 @@ require 'optparse'
3
3
 
4
4
  class Parser
5
5
  def self.parse_options
6
- options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true}
6
+ options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ' }
7
7
 
8
8
  parser = OptionParser.new { |opts|
9
9
  opts.banner = 'Usage: changelog_generator [options]'
@@ -20,12 +20,15 @@ class Parser
20
20
  puts opts
21
21
  exit
22
22
  end
23
- opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
23
+ opts.on('-v', '--[no-]verbose', 'Run verbosely. Default is true') do |v|
24
24
  options[:verbose] = v
25
25
  end
26
26
  opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
27
27
  options[:issues] = v
28
28
  end
29
+ opts.on('--[no-]issues-without-labels', 'Include closed issues without any labels to changelog. Default is true') do |v|
30
+ options[:add_issues_wo_labels] = v
31
+ end
29
32
  opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
30
33
  options[:pulls] = v
31
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_changelog_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Korolev