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 +4 -4
- data/lib/github_changelog_generator.rb +23 -5
- data/lib/github_changelog_generator/parser.rb +10 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac3da4dd2dcab64819ab088aa8ed3acfa8ed79df
|
4
|
+
data.tar.gz: d15971ed4ac80d7bd2f58c43e055a1182b35be05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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[:
|
161
|
-
|
162
|
-
|
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 = (
|
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
|
10
|
-
opts.on('-u', '--user [USER]', '
|
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]', '
|
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
|
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', '
|
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]', '
|
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!
|