From f647dc0d98a59b6c080f5d082aca76afb1f47f74 Mon Sep 17 00:00:00 2001 From: James Casey Date: Wed, 31 Aug 2016 14:17:35 -0700 Subject: [PATCH] Change to use Rainbow instead of colorize colorize is licensed under GPL-2 which conflicts with the MIT license of github_changelog_generator. This changes all usage of colorize to rainbow which does have a compatible license (MIT) --- Gemfile.lock | 3 +-- github_changelog_generator.gemspec | 2 +- lib/github_changelog_generator.rb | 2 +- lib/github_changelog_generator/fetcher.rb | 26 +++++++++---------- .../generator/generator_fetcher.rb | 2 +- .../generator/generator_generation.rb | 4 +-- .../generator/generator_tags.rb | 2 +- lib/github_changelog_generator/helper.rb | 10 +++---- 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fc93bed..b77628b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: github_changelog_generator (1.13.1) - colorize (>= 0.7) + rainbow (>= 2.1) github_api (>= 0.12) rake (>= 10.0) @@ -15,7 +15,6 @@ GEM ffi (~> 1.0, >= 1.0.11) codeclimate-test-reporter (0.6.0) simplecov (>= 0.7.1, < 1.0.0) - colorize (0.8.1) coveralls (0.8.14) json (>= 1.8, < 3) simplecov (~> 0.12.0) diff --git a/github_changelog_generator.gemspec b/github_changelog_generator.gemspec index 178cb73..3d785ca 100644 --- a/github_changelog_generator.gemspec +++ b/github_changelog_generator.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "rake", ">= 10.0" spec.add_runtime_dependency "github_api", ">= 0.12" - spec.add_runtime_dependency "colorize", ">= 0.7" + spec.add_runtime_dependency "rainbow", ">= 2.1" spec.add_development_dependency "overcommit", ">= 0.31" spec.add_development_dependency "rspec", ">= 3.2" diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index c689c95..2a51a32 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -2,7 +2,7 @@ require "github_api" require "json" -require "colorize" +require "rainbow/ext/string" require "benchmark" require_relative "github_changelog_generator/helper" diff --git a/lib/github_changelog_generator/fetcher.rb b/lib/github_changelog_generator/fetcher.rb index c5a0748..4a4bf5d 100644 --- a/lib/github_changelog_generator/fetcher.rb +++ b/lib/github_changelog_generator/fetcher.rb @@ -34,7 +34,7 @@ module GitHubChangelogGenerator def fetch_github_token env_var = @options[:token] ? @options[:token] : (ENV.fetch CHANGELOG_GITHUB_TOKEN, nil) - Helper.log.warn NO_TOKEN_PROVIDED.yellow unless env_var + Helper.log.warn NO_TOKEN_PROVIDED.color(:yellow) unless env_var env_var end @@ -53,11 +53,11 @@ module GitHubChangelogGenerator begin value = yield rescue Github::Error::Unauthorized => e - Helper.log.error e.response_message.red + Helper.log.error e.response_message.color(:red) abort "Error: wrong GitHub token" rescue Github::Error::Forbidden => e - Helper.log.warn e.response_message.red - Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow + Helper.log.warn e.response_message.color(:red) + Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow) end value end @@ -78,7 +78,7 @@ module GitHubChangelogGenerator if tags.count == 0 Helper.log.warn "Warning: Can't find any tags in repo.\ -Make sure, that you push tags to remote repo via 'git push --tags'".yellow +Make sure, that you push tags to remote repo via 'git push --tags'".color(:yellow) else Helper.log.info "Found #{tags.count} tags" end @@ -110,8 +110,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow Helper.log.info "Received issues: #{issues.count}" rescue Github::Error::Forbidden => e - Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red - Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow + Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red) + Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow) end # separate arrays of issues and pull requests: @@ -145,8 +145,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow end print_empty_line rescue Github::Error::Forbidden => e - Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red - Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow + Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red) + Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow) end Helper.log.info "Fetching merged dates: #{pull_requests.count}" @@ -182,8 +182,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow issue[:events].concat(page) end rescue Github::Error::Forbidden => e - Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red - Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow + Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red) + Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow) end print_in_same_line("Fetching events for issues and PR: #{i + 1}/#{issues.count}") i += 1 @@ -209,8 +209,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow @options[:project], tag["commit"]["sha"] rescue Github::Error::Forbidden => e - Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red - Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow + Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red) + Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow) end time_string = commit_data["committer"]["date"] Time.parse(time_string) diff --git a/lib/github_changelog_generator/generator/generator_fetcher.rb b/lib/github_changelog_generator/generator/generator_fetcher.rb index 988f3ed..9e12b2f 100644 --- a/lib/github_changelog_generator/generator/generator_fetcher.rb +++ b/lib/github_changelog_generator/generator/generator_fetcher.rb @@ -74,7 +74,7 @@ module GitHubChangelogGenerator commit = @fetcher.fetch_commit(event) issue[:actual_date] = commit[:author][:date] rescue - puts "Warning: Can't fetch commit #{event[:commit_id]}. It is probably referenced from another repo.".yellow + puts "Warning: Can't fetch commit #{event[:commit_id]}. It is probably referenced from another repo.".color(:yellow) issue[:actual_date] = issue[:closed_at] end end diff --git a/lib/github_changelog_generator/generator/generator_generation.rb b/lib/github_changelog_generator/generator/generator_generation.rb index 44df8df..d0fa9cc 100644 --- a/lib/github_changelog_generator/generator/generator_generation.rb +++ b/lib/github_changelog_generator/generator/generator_generation.rb @@ -39,10 +39,10 @@ module GitHubChangelogGenerator index2 = hash[tag2] log += generate_log_between_tags(all_tags[index1], all_tags[index2]) else - raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red + raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".color(:red) end else - raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red + raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".color(:red) end log end diff --git a/lib/github_changelog_generator/generator/generator_tags.rb b/lib/github_changelog_generator/generator/generator_tags.rb index 97e43b0..7f231f7 100644 --- a/lib/github_changelog_generator/generator/generator_tags.rb +++ b/lib/github_changelog_generator/generator/generator_tags.rb @@ -19,7 +19,7 @@ module GitHubChangelogGenerator # @param [Hash] tag_name name of the tag # @return [Time] time of specified tag def get_time_of_tag(tag_name) - raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil? + raise ChangelogGeneratorError, "tag_name is nil".color(:red) if tag_name.nil? name_of_tag = tag_name["name"] time_for_name = @tag_times_hash[name_of_tag] diff --git a/lib/github_changelog_generator/helper.rb b/lib/github_changelog_generator/helper.rb index 15789ec..fa48bd6 100644 --- a/lib/github_changelog_generator/helper.rb +++ b/lib/github_changelog_generator/helper.rb @@ -15,15 +15,15 @@ module GitHubChangelogGenerator string = "#{msg}\n" if severity == "DEBUG" - string = string.magenta + string = string.color(:magenta) elsif severity == "INFO" - string = string.white + string = string.color(:white) elsif severity == "WARN" - string = string.yellow + string = string.color(:yellow) elsif severity == "ERROR" - string = string.red + string = string.color(:red) elsif severity == "FATAL" - string = string.red.bold + string = string.color(:red).bright end string