github_changelog_generator 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 252bfdf546f6b2c416fcf8b85dd231fb96417153
4
- data.tar.gz: ff44c3c803bfd6609e2728d9e96d68fae222a88e
3
+ metadata.gz: 8155f1e7ea3677c3d367f637a07fb6de0cea418d
4
+ data.tar.gz: 4e2f2af6c503c0900dab6b473f03aaecaa23fa4a
5
5
  SHA512:
6
- metadata.gz: 0b67d7a6b43035f09de7d98886df5bd8e48243d9135b370811fd3c9679ff171937d6c3e2916673690c5b9b1036b3a7b9bb2157d0a9ecc7e5aed400ec510b6a25
7
- data.tar.gz: 4054d1d2c7e3f60947b9a783a9f73d7125f8dc5498cb440341a213869750dabd572a03bc50a18f09c019ea38696d65f788009e9b37054356ff20a134c58ed323
6
+ metadata.gz: 17d13e3e44f54241ced0f06c58b2f5fbfa24235a3e5c104c218157c15b063edabd84a39b096e6714a5cef539e733882170866364754d251d21fd570a211dacc6
7
+ data.tar.gz: fb0c0aa4a2173ad2b6137626270b25d2fe91821099b6f0f60fdd494ac58e627e54f27970afc9946b128eb0cb0e442b79e35a410235f43707a7d43a93a4f39790
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update --system
4
+ - gem --version
5
+ rvm:
6
+ - 2.1.0
7
+ gemfile:
8
+ - Gemfile
9
+
10
+ notifications:
11
+ email:
12
+ recipients:
13
+ - sky4winder+githubchangeloggenerator@gmail.com
14
+ on_success: never # [always|never|change]
15
+ on_failure: change # [always|never|change]
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.1)
4
+ #### 22/11/14
5
+ - *Merged pull-request:* Issues for last tag not in list [\#29](https://github.com/skywinder/Github-Changelog-Generator/pull/29) ([skywinder](https://github.com/skywinder))
6
+
7
+ - *Merged pull-request:* Disable default --filter-pull-requests option. [\#28](https://github.com/skywinder/Github-Changelog-Generator/pull/28) ([skywinder](https://github.com/skywinder))
8
+
3
9
  ## [1.2.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.0)
4
10
  #### 19/11/14
5
11
  - *Merged pull-request:* Add filter for pull-requests labels. (option --filter-pull-requests) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder))
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gem 'github_api'
3
- gem 'colorize'
3
+ gem 'colorize'
4
+ gem 'rake'
data/Gemfile.lock CHANGED
@@ -30,6 +30,7 @@ GEM
30
30
  multi_xml (~> 0.5)
31
31
  rack (~> 1.2)
32
32
  rack (1.5.2)
33
+ rake (10.4.2)
33
34
  thread_safe (0.3.4)
34
35
 
35
36
  PLATFORMS
@@ -38,3 +39,4 @@ PLATFORMS
38
39
  DEPENDENCIES
39
40
  colorize
40
41
  github_api
42
+ rake
data/README.md CHANGED
@@ -2,6 +2,7 @@ GitHub Changelog Generator
2
2
  ==================
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/github_changelog_generator.svg)](http://badge.fury.io/rb/github_changelog_generator)
5
+ [![Build Status](https://travis-ci.org/skywinder/Github-Changelog-Generator.svg?branch=master)](https://travis-ci.org/skywinder/Github-Changelog-Generator)
5
6
 
6
7
  Changelog generation has never been so easy.
7
8
 
@@ -15,17 +16,17 @@ You're almost done!
15
16
  ## Usage
16
17
  **It's really simple**:
17
18
 
18
- - `cd` to your Project folder with configured git and just type:
19
+ - If your **git remote** `origin` refer to your GitHub repo, then just go to your project folder just run:
19
20
 
20
21
  github_changelog_generator
21
22
 
22
- - from anywhere:
23
+ - or from anywhere:
23
24
 
24
25
  github_changelog_generator -u github-username -p github-project
25
26
 
26
27
  As output you will get `CHANGELOG.md` file with *pretty Markdown-formatted* changelog.
27
28
 
28
- ## Params:
29
+ ### Params:
29
30
  Type `github_changelog_generator --help` for detailed usage.
30
31
 
31
32
  Usage: changelog_generator [options]
@@ -44,22 +45,16 @@ Type `github_changelog_generator --help` for detailed usage.
44
45
  --labels x,y,z List of labels. Issues with that labels will be included to changelog. Default is 'bug,enhancement'
45
46
  -v, --version Print version number
46
47
 
47
- ## Examples:
48
-
49
- - Look at **[CHANGELOG.md](https://github.com/skywinder/Github-Changelog-Generator/blob/master/CHANGELOG.md)** for **this** project
50
- - [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by command:
51
-
52
- github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
53
48
 
49
+ ### GitHub token
54
50
 
55
- ## FAQ:
56
51
  Since GitHub allow to make only 50 requests without authentication it's recommended to run this script with token
57
52
 
58
53
  **You can easily [generate it here](https://github.com/settings/applications)**.
59
54
 
60
55
  And:
61
56
 
62
- - Run with key `-t [your-16-digit-token]` that
57
+ - Run with key `-t [your-16-digit-token]`
63
58
  - Or set environment variable `CHANGELOG_GITHUB_TOKEN` and specify there your token.
64
59
 
65
60
  i.e. add to your `~/.bash_profile` or `~/.zshrc` or any other place to load ENV variables string `export CHANGELOG_GITHUB_TOKEN="your-40-digit-github-token"'`
@@ -69,6 +64,19 @@ So, if you got error like this:
69
64
 
70
65
  It's time to create this token or wait for 1 hour before GitHub reset the counter for your IP.
71
66
 
67
+ ## Examples:
68
+
69
+ - Look at **[CHANGELOG.md](https://github.com/skywinder/Github-Changelog-Generator/blob/master/CHANGELOG.md)** for **this** project
70
+ - [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by command:
71
+
72
+ github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
73
+
74
+
75
+ ## Projects using this library
76
+ [Wikipage with list of projects](https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator)
77
+
78
+ *If you are using `github_changelog_generator` for generation chamgelog in your project or know of project that uses it, please add it to [this] (https://github.com/skywinder/Github-Changelog-Generator/wiki/Projects-using-Github-Changelog-Generator) list.*
79
+
72
80
  ## Am I missed some essential feature?
73
81
 
74
82
  **Nothing is impossible!** Open an [issue](https://github.com/skywinder/Github-Changelog-Generator/issues/new) and let's make generator better together!
@@ -87,3 +95,7 @@ It's time to create this token or wait for 1 hour before GitHub reset the counte
87
95
  ## License
88
96
 
89
97
  Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
98
+
99
+
100
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/skywinder/github-changelog-generator/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
101
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "rake/testtask"
2
+
3
+ task :default => [:test]
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.verbose = true
7
+ t.libs.push("demo", "test")
8
+ t.pattern = "test/**/*_test.rb"
9
+ end
@@ -4,6 +4,7 @@ require 'github_api'
4
4
  require 'json'
5
5
  require 'colorize'
6
6
  require_relative 'github_changelog_generator/parser'
7
+ require_relative 'github_changelog_generator/generator'
7
8
  require_relative 'github_changelog_generator/version'
8
9
 
9
10
  module GitHubChangelogGenerator
@@ -29,6 +30,8 @@ module GitHubChangelogGenerator
29
30
  @github = Github.new oauth_token: @github_token
30
31
  end
31
32
 
33
+ @generator = Generator.new(@options)
34
+
32
35
  @all_tags = self.get_all_tags
33
36
  @pull_requests = self.get_all_closed_pull_requests
34
37
  if @options[:issues]
@@ -111,7 +114,6 @@ module GitHubChangelogGenerator
111
114
  if @options[:last]
112
115
  log += self.generate_log_between_tags(self.all_tags[0], self.all_tags[1])
113
116
  elsif @options[:tag1] and @options[:tag2]
114
-
115
117
  tag1 = @options[:tag1]
116
118
  tag2 = @options[:tag2]
117
119
  tags_strings = []
@@ -140,7 +142,7 @@ module GitHubChangelogGenerator
140
142
  output_filename = "#{@options[:output]}"
141
143
  File.open(output_filename, 'w') { |file| file.write(log) }
142
144
 
143
- puts "Done! Generated log placed in #{output_filename}"
145
+ puts "Done! Generated log placed in #{`pwd`.strip!}/#{output_filename}"
144
146
 
145
147
  end
146
148
 
@@ -159,11 +161,11 @@ module GitHubChangelogGenerator
159
161
  puts "Generating log.."
160
162
  end
161
163
 
162
- for index in 1 ... self.all_tags.size
164
+ (1 ... self.all_tags.size).each { |index|
163
165
  log += self.generate_log_between_tags(self.all_tags[index], self.all_tags[index-1])
164
- end
166
+ }
165
167
 
166
- log += self.generate_log_before_tag(self.all_tags.last)
168
+ log += generate_log_between_tags(nil, self.all_tags.last)
167
169
 
168
170
  log
169
171
  end
@@ -216,14 +218,14 @@ module GitHubChangelogGenerator
216
218
 
217
219
  if older_tag.nil?
218
220
  filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time)
219
- issues = delete_by_time(@issues, :closed_at, newer_tag_time)
221
+ filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time)
220
222
  else
221
223
  older_tag_time = self.get_time_of_tag(older_tag)
222
224
  filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, newer_tag_time, older_tag_time)
223
- issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
225
+ filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
224
226
  end
225
227
 
226
- self.create_log(filtered_pull_requests, issues, newer_tag_name, newer_tag_time)
228
+ self.create_log(filtered_pull_requests, filtered_issues, newer_tag_name, newer_tag_time)
227
229
 
228
230
  end
229
231
 
@@ -241,7 +243,7 @@ module GitHubChangelogGenerator
241
243
  tag_in_range_new = t <= newer_tag_time
242
244
 
243
245
  tag_in_range = (tag_in_range_old) && (tag_in_range_new)
244
-
246
+
245
247
  tag_in_range
246
248
  else
247
249
  false
@@ -249,15 +251,15 @@ module GitHubChangelogGenerator
249
251
  }
250
252
  end
251
253
 
252
- def generate_log_before_tag(tag)
253
- generate_log_between_tags(nil, tag)
254
- end
255
-
254
+ # @param [Array] pull_requests
255
+ # @param [Array] issues
256
+ # @param [String] tag_name
257
+ # @param [String] tag_time
258
+ # @return [String]
256
259
  def create_log(pull_requests, issues, tag_name, tag_time)
257
260
 
258
261
  # Generate tag name and link
259
- trimmed_tag = tag_name.tr('v', '')
260
- log = "## [#{trimmed_tag}] (https://github.com/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n"
262
+ log = "## [#{tag_name}] (https://github.com/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n"
261
263
 
262
264
  #Generate date string:
263
265
  time_string = tag_time.strftime @options[:format]
@@ -265,20 +267,11 @@ module GitHubChangelogGenerator
265
267
 
266
268
  if @options[:pulls]
267
269
  # Generate pull requests:
268
- if pull_requests
269
- if @options[:author]
270
- pull_requests.each { |dict|
271
- merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url}) ([#{dict.user.login}](#{dict.user.html_url}))\n\n"
272
- log += "- #{merge}"
273
- }
274
- else
275
- pull_requests.each { |dict|
276
- merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
277
- log += "- #{merge}"
278
- }
279
- end
270
+ pull_requests.each { |pull_request|
271
+ merge = @generator.get_string_for_pull_request(pull_request)
272
+ log += "- #{merge}"
280
273
 
281
- end
274
+ } if pull_requests
282
275
  end
283
276
 
284
277
  if @options[:issues]
@@ -321,7 +314,9 @@ module GitHubChangelogGenerator
321
314
  intro = 'Implemented enhancement'
322
315
  end
323
316
 
324
- merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
317
+ enc_string = @generator.encapsulate_string dict[:title]
318
+
319
+ merge = "*#{intro}:* #{enc_string} [\\##{dict[:number]}](#{dict.html_url})\n\n"
325
320
  log += "- #{merge}"
326
321
  }
327
322
  end
@@ -0,0 +1,34 @@
1
+ module GitHubChangelogGenerator
2
+ class Generator
3
+
4
+ def initialize(options = nil)
5
+ @options = options
6
+ end
7
+
8
+ def get_string_for_pull_request(pull_request)
9
+ encapsulated_title = self.encapsulate_string pull_request[:title]
10
+
11
+ merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
12
+ if @options[:author]
13
+ merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
14
+ else
15
+ merge += "\n\n"
16
+ end
17
+ merge
18
+ end
19
+
20
+ def encapsulate_string(string)
21
+
22
+ string.gsub! '\\', '\\\\'
23
+
24
+ encpas_chars = %w(> * _ \( \) [ ])
25
+ encpas_chars.each{ |char|
26
+ string.gsub! char, "\\#{char}"
27
+ }
28
+
29
+ string
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -16,12 +16,14 @@ module GitHubChangelogGenerator
16
16
  opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub') do |last|
17
17
  options[:project] = last
18
18
  end
19
- opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this script required your OAuth token for GitHub. You can generate here: https://github.com/settings/tokens/new') do |last|
19
+ opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests per hour your GitHub token required. You can generate it here: https://github.com/settings/tokens/new') do |last|
20
20
  options[:token] = last
21
21
  end
22
- opts.on('-h', '--help', 'Displays Help') do
23
- puts opts
24
- exit
22
+ opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %d/%m/%y') do |last|
23
+ options[:format] = last
24
+ end
25
+ opts.on('-o', '--output [NAME]', 'Output file. Default is CHANGELOG.md') do |last|
26
+ options[:output] = last
25
27
  end
26
28
  opts.on('--[no-]verbose', 'Run verbosely. Default is true') do |v|
27
29
  options[:verbose] = v
@@ -35,28 +37,23 @@ module GitHubChangelogGenerator
35
37
  opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
36
38
  options[:pulls] = v
37
39
  end
38
- opts.on('-l', '--last-changes', 'Generate log between last 2 tags only') do |last|
39
- options[:last] = last
40
- end
41
40
  opts.on('--[no-]author', 'Add author of pull-request in the end. Default is true') do |author|
42
41
  options[:last] = author
43
42
  end
44
- opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %d/%m/%y') do |last|
45
- options[:format] = last
46
- end
47
- opts.on('-o', '--output [NAME]', 'Output file. Default is CHANGELOG.md') do |last|
48
- options[:output] = last
49
- end
50
43
  opts.on('--labels x,y,z', Array, 'Issues with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list|
51
44
  options[:labels] = list
52
45
  end
53
- opts.on('--filter-pull-requests x,y,z', Array, 'Pull requests with that labels will be included to changelog. pull requests w\o labels will be included anyway.') do |list|
46
+ opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list|
54
47
  options[:pull_request_labels] = list
55
48
  end
56
49
  opts.on('-v', '--version', 'Print version number') do |v|
57
50
  puts "Version: #{GitHubChangelogGenerator::VERSION}"
58
51
  exit
59
52
  end
53
+ opts.on('-h', '--help', 'Displays Help') do
54
+ puts opts
55
+ exit
56
+ end
60
57
  }
61
58
 
62
59
  parser.parse!
@@ -1,3 +1,3 @@
1
1
  module GitHubChangelogGenerator
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_changelog_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Korolev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-22 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,14 +74,17 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".travis.yml"
77
78
  - CHANGELOG.md
78
79
  - Gemfile
79
80
  - Gemfile.lock
80
81
  - README.md
82
+ - Rakefile
81
83
  - bin/github_changelog_generator
82
84
  - bump_gemfile.rb
83
85
  - github_changelog_generator.gemspec
84
86
  - lib/github_changelog_generator.rb
87
+ - lib/github_changelog_generator/generator.rb
85
88
  - lib/github_changelog_generator/parser.rb
86
89
  - lib/github_changelog_generator/version.rb
87
90
  homepage: https://github.com/skywinder/Github-Changelog-Generator
@@ -104,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
107
  version: '0'
105
108
  requirements: []
106
109
  rubyforge_project:
107
- rubygems_version: 2.4.3
110
+ rubygems_version: 2.4.4
108
111
  signing_key:
109
112
  specification_version: 4
110
113
  summary: Script, that automatically generate change-log from your tags and pull-requests.