github_changelog_generator 0.0.2 → 0.1.0

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: b7ce284350b7b4f261202e298057a84e911b67d1
4
- data.tar.gz: f7f9f8d309212ef49989f283460fd2138cac4ec6
3
+ metadata.gz: ac3da4dd2dcab64819ab088aa8ed3acfa8ed79df
4
+ data.tar.gz: d15971ed4ac80d7bd2f58c43e055a1182b35be05
5
5
  SHA512:
6
- metadata.gz: fa6ea6757cbe39acff9dba293a78acf05c153a9ebe17504f08cc7da39126744ce7fae306012b08ca03183ab3024a963c2300f7861fad7cff8a0ec968043437a9
7
- data.tar.gz: f286b75ae31ea3c1ce9118cf3e6a6145a8a8c90f02b6b8e4df42eaf779a50115c3bb5263abc127869ed750747efd03be1a85c2a07a3de03935ae15af692d4271
6
+ metadata.gz: 5da1acfbda00a6d208375507d3303f717f96b83d48e9d57dc844619a2bcc0ab992849b0e6d84802a69cc31c79121487bce72fc5e557070542d2c5f053a5e3dac
7
+ data.tar.gz: ab9881fadfe743ed99a13d795dbdf0b6f663d695fd74c6347f673cc194bebbfae913d1f40d591ed9308e861a33fcd71c3e5d577126d958cf15e528d63b8e6885
@@ -88,7 +88,8 @@ class ChangelogGenerator
88
88
  end
89
89
 
90
90
  log += "\n\n*This file was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
91
- output_filename = "#{@options[:project]}_CHANGELOG.md"
91
+
92
+ output_filename = "#{@options[:output]}"
92
93
  File.open(output_filename, 'w') { |file| file.write(log) }
93
94
 
94
95
  puts "Done! Generated log placed in #{output_filename}"
@@ -101,6 +102,8 @@ class ChangelogGenerator
101
102
  log += self.generate_log_between_tags(self.all_tags[index-1], self.all_tags[index])
102
103
  end
103
104
 
105
+ log += self.generate_log_before_tag(self.all_tags.last)
106
+
104
107
  log
105
108
  end
106
109
 
@@ -157,17 +160,32 @@ class ChangelogGenerator
157
160
  pull_requests = Array.new(@pull_requests)
158
161
 
159
162
  pull_requests.delete_if { |req|
160
- t = Time.parse(req[:closed_at]).utc
161
- true_classor_false_class = t > since_tag_time
162
- classor_false_class = t < till_tag_time
163
+ t = Time.parse(req[:merged_at]).utc
164
+ tag_is_later_since = t > since_tag_time
165
+ tag_is_before_till = t <= till_tag_time
163
166
 
164
- in_range = (true_classor_false_class) && (classor_false_class)
167
+ in_range = (tag_is_later_since) && (tag_is_before_till)
165
168
  !in_range
166
169
  }
167
170
 
168
171
  self.create_log(pull_requests, till_tag_name, till_tag_time)
169
172
  end
170
173
 
174
+ def generate_log_before_tag(tag)
175
+ tag_time = self.get_time_of_tag(tag)
176
+ tag_name = tag['name']
177
+
178
+ pull_requests = Array.new(@pull_requests)
179
+
180
+ pull_requests.delete_if { |req|
181
+ t = Time.parse(req[:closed_at]).utc
182
+ t > tag_time
183
+ }
184
+
185
+ self.create_log(pull_requests, tag_name, tag_time)
186
+
187
+ end
188
+
171
189
  def create_log(pull_requests, tag_name, tag_time)
172
190
 
173
191
  trimmed_tag = tag_name.tr('v', '')
@@ -3,17 +3,17 @@ require 'optparse'
3
3
 
4
4
  class Parser
5
5
  def self.parse_options
6
- options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y'}
6
+ options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md'}
7
7
 
8
8
  parser = OptionParser.new { |opts|
9
- opts.banner = 'Usage: changelog_generator -u user_name -p project_name [-t 16-digit-GitHubToken] [options]'
10
- opts.on('-u', '--user [USER]', 'your username on GitHub') do |last|
9
+ opts.banner = 'Usage: changelog_generator --user username --project project_name [options]'
10
+ opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo (required)') do |last|
11
11
  options[:user] = last
12
12
  end
13
- opts.on('-p', '--project [PROJECT]', 'name of project on GitHub') do |last|
13
+ opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub (required)') do |last|
14
14
  options[:project] = last
15
15
  end
16
- opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this app required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications') do |last|
16
+ opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this script required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications') do |last|
17
17
  options[:token] = last
18
18
  end
19
19
  opts.on('-h', '--help', 'Displays Help') do
@@ -23,12 +23,15 @@ class Parser
23
23
  opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
24
24
  options[:verbose] = v
25
25
  end
26
- opts.on('-l', '--last-changes', 'generate log between last 2 tags') do |last|
26
+ opts.on('-l', '--last-changes', 'Generate log between only last 2 tags') do |last|
27
27
  options[:last] = last
28
28
  end
29
- opts.on('-f', '--date-format [FORMAT]', 'date format. default is %d/%m/%y') do |last|
29
+ opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %d/%m/%y') do |last|
30
30
  options[:format] = last
31
31
  end
32
+ opts.on('-o', '--output [FORMAT]', 'Output file. Default is CHANGELOG.md') do |last|
33
+ options[:output] = last
34
+ end
32
35
  }
33
36
 
34
37
  parser.parse!
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: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Korolev