diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index e1e78b3..59664f1 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -1,23 +1,5 @@ # Change Log -## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04) - -[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...v0.0.3) - -**Merged pull requests:** - -- fix \#3. hotfix. Should appear in v0.0.3 [\#4](https://github.com/skywinder/changelog_test/pull/4) ([skywinder](https://github.com/skywinder)) - -## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04) - -[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2) - -**Merged pull requests:** - -- 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)) - -## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02) - \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 4ff4a1b..25be853 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -20,13 +20,7 @@ module GitHubChangelogGenerator @options = Parser.parse_options - if options[:verbose] - puts 'Input options:' - pp options - puts '' - end - - github_token + fetch_github_token github_options = {per_page: PER_PAGE_NUMBER} github_options[:oauth_token] = @github_token unless @github_token.nil? @@ -113,11 +107,6 @@ module GitHubChangelogGenerator puts JSON.pretty_generate(json) end - def exec_command(cmd) - exec_cmd = "cd #{$project_path} and #{cmd}" - %x[#{exec_cmd}] - end - def fetch_merged_at_pull_requests if @options[:verbose] print "Fetching merged dates...\r" @@ -240,7 +229,7 @@ module GitHubChangelogGenerator log = '' - if @options[:unreleased] + if @options[:unreleased] && @all_tags.count != 0 unreleased_log = self.generate_log_between_tags(self.all_tags[0], nil) if unreleased_log log += unreleased_log @@ -250,8 +239,9 @@ module GitHubChangelogGenerator (1 ... self.all_tags.size).each { |index| log += self.generate_log_between_tags(self.all_tags[index], self.all_tags[index-1]) } - - log += generate_log_between_tags(nil, self.all_tags.last) + if @all_tags.count != 0 + log += generate_log_between_tags(nil, self.all_tags.last) + end log end @@ -314,12 +304,8 @@ module GitHubChangelogGenerator tags end - def github_token - if @options[:token] - return @github_token ||= @options[:token] - end - - env_var = ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil + def fetch_github_token + env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil) unless env_var puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow @@ -389,7 +375,7 @@ module GitHubChangelogGenerator def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil) - raise 'At least on of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?) + raise 'At least one of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?) newer_tag_time = self.get_time_of_tag(newer_tag) older_tag_time = self.get_time_of_tag(older_tag) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 3c8b5cd..fd0723c 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,8 +6,8 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - # :include_labels => %w(bug enhancement), - hash = { + + options = { :tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', @@ -28,7 +28,6 @@ module GitHubChangelogGenerator :unreleased => true, :unreleased_label => 'Unreleased' } - options = hash parser = OptionParser.new { |opts| opts.banner = 'Usage: github_changelog_generator [options]' @@ -149,6 +148,12 @@ module GitHubChangelogGenerator options[:tag2] = ARGV[1] end + if options[:verbose] + puts 'Performing task with options:' + pp options + puts '' + end + options end end diff --git a/lib/github_changelog_generator/version.rb b/lib/github_changelog_generator/version.rb index bce6426..051e366 100644 --- a/lib/github_changelog_generator/version.rb +++ b/lib/github_changelog_generator/version.rb @@ -1,3 +1,3 @@ module GitHubChangelogGenerator - VERSION = '1.3.5' + VERSION = '1.3.6' end