github_changelog_generator 1.0.1 → 1.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 +15 -10
- data/lib/github_changelog_generator/parser.rb +15 -4
- 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: 5f83cc895379430ee9e8613e77a63a10cec53de4
|
4
|
+
data.tar.gz: 59190fee38e70eff912d176f67b8facb5e8cf9ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0e1137eacbd273a7e2aa5b90a1e8070d84c5634df249efc40e218a99967c59b05547ad03d6803ff60bc0b408d08b3915fb25138522d4952f5cf9922799ebc33
|
7
|
+
data.tar.gz: 8f5a48ede2c1f7863dabe0cf3a70eda72a1e6cd721f54bc3d157715c217682bbee8a2dc041078c60836e0815e868476ba9c3616433a545ac4250b7b5149f207b
|
@@ -60,7 +60,7 @@ class ChangelogGenerator
|
|
60
60
|
tag1 = @options[:tag1]
|
61
61
|
tag2 = @options[:tag2]
|
62
62
|
tags_strings = []
|
63
|
-
self.all_tags.each { |x| tags_strings.push(x['name'])}
|
63
|
+
self.all_tags.each { |x| tags_strings.push(x['name']) }
|
64
64
|
|
65
65
|
if tags_strings.include?(tag1)
|
66
66
|
if tags_strings.include?(tag2)
|
@@ -117,9 +117,14 @@ class ChangelogGenerator
|
|
117
117
|
puts "Receive tags for repo #{url}"
|
118
118
|
end
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
if @options[:token]
|
121
|
+
response = HTTParty.get(url,
|
122
|
+
:headers => {'Authorization' => "token #{@options[:token]}",
|
123
|
+
'User-Agent' => 'Changelog-Generator'})
|
124
|
+
else
|
125
|
+
response = HTTParty.get(url,
|
126
|
+
:headers => {'User-Agent' => 'Changelog-Generator'})
|
127
|
+
end
|
123
128
|
|
124
129
|
json_parse = JSON.parse(response.body)
|
125
130
|
|
@@ -160,7 +165,7 @@ class ChangelogGenerator
|
|
160
165
|
|
161
166
|
issues = Array.new(@issues)
|
162
167
|
|
163
|
-
issues.delete_if{ |issue|
|
168
|
+
issues.delete_if { |issue|
|
164
169
|
if issue[:closed_at]
|
165
170
|
t = Time.parse(issue[:closed_at]).utc
|
166
171
|
tag_is_later_since = t > since_tag_time
|
@@ -196,7 +201,7 @@ class ChangelogGenerator
|
|
196
201
|
|
197
202
|
issues = Array.new(@issues)
|
198
203
|
|
199
|
-
issues.delete_if{ |issue|
|
204
|
+
issues.delete_if { |issue|
|
200
205
|
if issue[:closed_at]
|
201
206
|
t = Time.parse(issue[:closed_at]).utc
|
202
207
|
t > tag_time
|
@@ -234,19 +239,19 @@ class ChangelogGenerator
|
|
234
239
|
if issues
|
235
240
|
issues.each { |dict|
|
236
241
|
is_bug = false
|
237
|
-
is_enhancement
|
242
|
+
is_enhancement = false
|
238
243
|
dict.labels.each { |label|
|
239
244
|
if label.name == 'bug'
|
240
245
|
is_bug = true
|
241
246
|
end
|
242
247
|
if label.name == 'enhancement'
|
243
|
-
is_enhancement
|
248
|
+
is_enhancement = true
|
244
249
|
end
|
245
250
|
}
|
246
251
|
|
247
252
|
intro = 'Closed issue'
|
248
253
|
if is_bug
|
249
|
-
intro =
|
254
|
+
intro = 'Fixed bug'
|
250
255
|
end
|
251
256
|
|
252
257
|
if is_enhancement
|
@@ -298,4 +303,4 @@ end
|
|
298
303
|
if __FILE__ == $0
|
299
304
|
changelog_generator = ChangelogGenerator.new
|
300
305
|
changelog_generator.compund_changelog
|
301
|
-
end
|
306
|
+
end
|
@@ -3,14 +3,14 @@ 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
|
6
|
+
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true}
|
7
7
|
|
8
8
|
parser = OptionParser.new { |opts|
|
9
|
-
opts.banner = 'Usage: changelog_generator
|
10
|
-
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo
|
9
|
+
opts.banner = 'Usage: changelog_generator [options]'
|
10
|
+
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo') do |last|
|
11
11
|
options[:user] = last
|
12
12
|
end
|
13
|
-
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub
|
13
|
+
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub') do |last|
|
14
14
|
options[:project] = last
|
15
15
|
end
|
16
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|
|
@@ -51,6 +51,17 @@ class Parser
|
|
51
51
|
exit
|
52
52
|
end
|
53
53
|
|
54
|
+
if !options[:user] && !options[:project]
|
55
|
+
remote = `git remote -vv`.split("\n")
|
56
|
+
match = /.*(?:[:\/])(\w*)\/((?:-|\w)*)\.git.*/.match(remote[0])
|
57
|
+
|
58
|
+
if match[1] && match[2]
|
59
|
+
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
60
|
+
options[:user], options[:project] = match[1], match[2]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
54
65
|
if !options[:user] || !options[:project]
|
55
66
|
puts parser.banner
|
56
67
|
exit
|