Skip to content

Commit 27fa9e8

Browse files
committed
Merge branch 'hotfix/fix-nil-tag'
2 parents 3a200e9 + 0706f89 commit 27fa9e8

File tree

4 files changed

+17
-44
lines changed

4 files changed

+17
-44
lines changed

lib/CHANGELOG.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
# Change Log
22

3-
## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04)
4-
5-
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...v0.0.3)
6-
7-
**Merged pull requests:**
8-
9-
- fix \#3. hotfix. Should appear in v0.0.3 [\#4](https://github.com/skywinder/changelog_test/pull/4) ([skywinder](https://github.com/skywinder))
10-
11-
## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04)
12-
13-
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2)
14-
15-
**Merged pull requests:**
16-
17-
- Here is a test hotfix should appear in v.0.0.2 [\#2](https://github.com/skywinder/changelog_test/pull/2) ([skywinder](https://github.com/skywinder))
18-
19-
## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02)
20-
213

224

235
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

lib/github_changelog_generator.rb

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ def initialize
2020

2121
@options = Parser.parse_options
2222

23-
if options[:verbose]
24-
puts 'Input options:'
25-
pp options
26-
puts ''
27-
end
28-
29-
github_token
23+
fetch_github_token
3024

3125
github_options = {per_page: PER_PAGE_NUMBER}
3226
github_options[:oauth_token] = @github_token unless @github_token.nil?
@@ -113,11 +107,6 @@ def print_json(json)
113107
puts JSON.pretty_generate(json)
114108
end
115109

116-
def exec_command(cmd)
117-
exec_cmd = "cd #{$project_path} and #{cmd}"
118-
%x[#{exec_cmd}]
119-
end
120-
121110
def fetch_merged_at_pull_requests
122111
if @options[:verbose]
123112
print "Fetching merged dates...\r"
@@ -240,7 +229,7 @@ def generate_log_for_all_tags
240229

241230
log = ''
242231

243-
if @options[:unreleased]
232+
if @options[:unreleased] && @all_tags.count != 0
244233
unreleased_log = self.generate_log_between_tags(self.all_tags[0], nil)
245234
if unreleased_log
246235
log += unreleased_log
@@ -250,8 +239,9 @@ def generate_log_for_all_tags
250239
(1 ... self.all_tags.size).each { |index|
251240
log += self.generate_log_between_tags(self.all_tags[index], self.all_tags[index-1])
252241
}
253-
254-
log += generate_log_between_tags(nil, self.all_tags.last)
242+
if @all_tags.count != 0
243+
log += generate_log_between_tags(nil, self.all_tags.last)
244+
end
255245

256246
log
257247
end
@@ -314,12 +304,8 @@ def get_all_tags
314304
tags
315305
end
316306

317-
def github_token
318-
if @options[:token]
319-
return @github_token ||= @options[:token]
320-
end
321-
322-
env_var = ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil
307+
def fetch_github_token
308+
env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil)
323309

324310
unless env_var
325311
puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow
@@ -389,7 +375,7 @@ def filter_by_milestone(filtered_issues, newer_tag_name, src_array)
389375

390376
def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)
391377

392-
raise 'At least on of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?)
378+
raise 'At least one of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?)
393379

394380
newer_tag_time = self.get_time_of_tag(newer_tag)
395381
older_tag_time = self.get_time_of_tag(older_tag)

lib/github_changelog_generator/parser.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
module GitHubChangelogGenerator
77
class Parser
88
def self.parse_options
9-
# :include_labels => %w(bug enhancement),
10-
hash = {
9+
10+
options = {
1111
:tag1 => nil,
1212
:tag2 => nil,
1313
:format => '%Y-%m-%d',
@@ -28,7 +28,6 @@ def self.parse_options
2828
:unreleased => true,
2929
:unreleased_label => 'Unreleased'
3030
}
31-
options = hash
3231

3332
parser = OptionParser.new { |opts|
3433
opts.banner = 'Usage: github_changelog_generator [options]'
@@ -149,6 +148,12 @@ def self.parse_options
149148
options[:tag2] = ARGV[1]
150149
end
151150

151+
if options[:verbose]
152+
puts 'Performing task with options:'
153+
pp options
154+
puts ''
155+
end
156+
152157
options
153158
end
154159
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module GitHubChangelogGenerator
2-
VERSION = '1.3.5'
2+
VERSION = '1.3.6'
33
end

0 commit comments

Comments
 (0)