Merge branch 'hotfix/fix-travis' into develop

This commit is contained in:
Petr Korolev 2015-03-27 15:54:04 +02:00
commit 2456db0847
6 changed files with 58 additions and 77 deletions

View File

@ -2,3 +2,7 @@ inherit_from: .rubocop_todo.yml
Metrics/LineLength:
Enabled: false
#http://viget.com/extend/just-use-double-quoted-ruby-strings
#Style/StringLiterals:
# EnforcedStyle: double_quotes

View File

@ -1,5 +1,5 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-03-26 22:36:26 +0200 using RuboCop version 0.29.1.
# on 2015-03-27 03:03:45 +0200 using RuboCop version 0.29.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@ -16,26 +16,16 @@ Metrics/BlockNesting:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 483
Max: 471
# Offense count: 6
Metrics/CyclomaticComplexity:
Max: 18
# Offense count: 81
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 213
# Offense count: 26
# Offense count: 27
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 145
# Offense count: 1
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6
Max: 147
# Offense count: 6
Metrics/PerceivedComplexity:
@ -75,7 +65,7 @@ Style/GlobalVars:
Style/GuardClause:
Enabled: false
# Offense count: 18
# Offense count: 17
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Enabled: false
@ -85,11 +75,6 @@ Style/IfUnlessModifier:
Style/Next:
Enabled: false
# Offense count: 1
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
Enabled: false
# Offense count: 5
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:

View File

@ -1,5 +1,8 @@
[![Gem Version](https://badge.fury.io/rb/github_changelog_generator.svg)](http://badge.fury.io/rb/github_changelog_generator)
[![Dependency Status](https://gemnasium.com/skywinder/github-changelog-generator.svg)](https://gemnasium.com/skywinder/github-changelog-generator)
[![Build Status](https://travis-ci.org/skywinder/github-changelog-generator.svg?branch=master)](https://travis-ci.org/skywinder/github-changelog-generator)
[![Coverage Status](http://img.shields.io/coveralls/skywinder/github-changelog-generator/master.svg)](https://coveralls.io/r/skywinder/github-changelog-generator)
[![Code Climate](https://codeclimate.com/github/skywinder/github-changelog-generator/badges/gpa.svg)](https://codeclimate.com/github/skywinder/github-changelog-generator)
[![Inline docs](http://inch-ci.org/github/skywinder/github-changelog-generator.svg)](http://inch-ci.org/github/skywinder/github-changelog-generator)
GitHub Changelog Generator ![GitHub Logo](../master/images/logo.jpg)
==================

View File

@ -1,4 +1,4 @@
#! /usr/bin/env ruby
require_relative '../lib/github_changelog_generator'
GitHubChangelogGenerator::ChangelogGenerator.new.compund_changelog
GitHubChangelogGenerator::ChangelogGenerator.new.compound_changelog

View File

@ -15,8 +15,8 @@ module GitHubChangelogGenerator
attr_accessor :options, :all_tags, :github
PER_PAGE_NUMBER = 30
GH_RATE_LIMIT_EXCEEDED_MSG = 'Warning: GitHub API rate limit exceed (5000 per hour), change log may not ' \
'contain some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument'
GH_RATE_LIMIT_EXCEEDED_MSG = 'Warning: GitHub API rate limit (5000 per hour) exceeded, change log may be ' \
'missing some issues. You can limit the number of issues fetched using the `--max-issues NUM` argument.'
def initialize
@options = Parser.parse_options
@ -95,7 +95,7 @@ module GitHubChangelogGenerator
commit = @github.git_data.commits.get @options[:user], @options[:project], event[:commit_id]
issue[:actual_date] = commit[:author][:date]
rescue
puts "Warning: can't fetch commit #{event[:commit_id]} probably it referenced from another repo.".yellow
puts "Warning: Can't fetch commit #{event[:commit_id]}. It is probably referenced from another repo.".yellow
issue[:actual_date] = issue[:closed_at]
end
end
@ -139,7 +139,7 @@ module GitHubChangelogGenerator
}
if @options[:verbose]
puts 'Fetching merged dates... Done!'
puts 'Fetching merged dates: Done!'
end
end
@ -150,7 +150,7 @@ module GitHubChangelogGenerator
unless @options[:include_labels].nil?
filtered_pull_requests = @pull_requests.select { |issue|
# add all labels from @options[:incluse_labels] array
# add all labels from @options[:include_labels] array
(issue.labels.map(&:name) & @options[:include_labels]).any?
}
end
@ -176,7 +176,7 @@ module GitHubChangelogGenerator
filtered_pull_requests
end
def compund_changelog
def compound_changelog
log = "# Change Log\n\n"
if @options[:unreleased_only]
@ -218,13 +218,13 @@ module GitHubChangelogGenerator
fetch_tags_dates
if @options[:verbose]
puts 'Sorting tags..'
puts 'Sorting tags...'
end
@all_tags.sort_by! { |x| get_time_of_tag(x) }.reverse!
if @options[:verbose]
puts 'Generating log..'
puts 'Generating log...'
end
log = ''
@ -248,7 +248,7 @@ module GitHubChangelogGenerator
def fetch_tags_dates
if @options[:verbose]
print "Fetching tags dates..\r"
print "Fetching tag dates...\r"
end
# Async fetching tags:
@ -275,12 +275,6 @@ module GitHubChangelogGenerator
end
end
def is_megred(number)
@github.pull_requests.merged? @options[:user], @options[:project], number
rescue
puts GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
def get_all_tags
if @options[:verbose]
print "Fetching tags...\r"
@ -298,12 +292,11 @@ module GitHubChangelogGenerator
tags.concat(page)
end
print " \r"
if @options[:verbose]
puts "Found #{tags.count} tags"
end
if tags.count == 0
puts "Warning: Can't find any tags in repo. Make sure, that you push tags to remote repo via 'git push --tags'".yellow
elsif @options[:verbose]
puts "Found #{tags.count} tags"
end
rescue
@ -318,7 +311,7 @@ module GitHubChangelogGenerator
unless env_var
puts 'Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.'.yellow
puts 'This script can make only 50 requests to GitHub API per hour without token!'.yellow
puts 'This script can make only 50 requests per hour to GitHub API without a token!'.yellow
end
@github_token ||= env_var
@ -417,23 +410,14 @@ module GitHubChangelogGenerator
# @param [String] older_tag_name
# @return [String]
def create_log(pull_requests, issues, newer_tag, older_tag_name = nil)
newer_tag_time = newer_tag.nil? ? nil : get_time_of_tag(newer_tag)
newer_tag_name = newer_tag.nil? ? nil : newer_tag['name']
newer_tag_time = newer_tag.nil? ? Time.new : get_time_of_tag(newer_tag)
newer_tag_name = newer_tag.nil? ? @options[:unreleased_label] : newer_tag['name']
newer_tag_link = newer_tag.nil? ? 'HEAD' : newer_tag_name
github_site = options[:github_site] || 'https://github.com'
project_url = "#{github_site}/#{@options[:user]}/#{@options[:project]}"
if newer_tag.nil?
newer_tag_name = @options[:unreleased_label]
newer_tag_link = 'HEAD'
newer_tag_time = Time.new
else
newer_tag_link = newer_tag_name
end
log = ''
log += generate_header(log, newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name, project_url)
log = generate_header(newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name, project_url)
if @options[:issues]
# Generate issues:
@ -488,9 +472,11 @@ module GitHubChangelogGenerator
log
end
def generate_header(log, newer_tag_name, newer_tag_name2, newer_tag_time, older_tag_name, project_url)
def generate_header(newer_tag_name, newer_tag_name2, newer_tag_time, older_tag_name, project_url)
log = ''
# Generate date string:
time_string = newer_tag_time.strftime @options[:format]
time_string = newer_tag_time.strftime @options[:dateformat]
# Generate tag name and link
if newer_tag_name.equal? @options[:unreleased_label]
@ -532,7 +518,7 @@ module GitHubChangelogGenerator
unless @options[:include_labels].nil?
filtered_issues = issues.select { |issue|
# add all labels from @options[:incluse_labels] array
# add all labels from @options[:include_labels] array
(issue.labels.map(&:name) & @options[:include_labels]).any?
}
end
@ -635,6 +621,6 @@ module GitHubChangelogGenerator
end
if __FILE__ == $PROGRAM_NAME
GitHubChangelogGenerator::ChangelogGenerator.new.compund_changelog
GitHubChangelogGenerator::ChangelogGenerator.new.compound_changelog
end
end

View File

@ -9,24 +9,27 @@ module GitHubChangelogGenerator
options = {
tag1: nil,
tag2: nil,
format: '%Y-%m-%d',
dateformat: '%Y-%m-%d',
output: 'CHANGELOG.md',
exclude_labels: %w(duplicate question invalid wontfix),
pulls: true,
issues: true,
verbose: true,
add_issues_wo_labels: true,
add_pr_wo_labels: true,
pulls: true,
filter_issues_by_milestone: true,
author: true,
unreleased: true,
unreleased_label: 'Unreleased',
compare_link: true,
include_labels: %w(bug enhancement),
exclude_labels: %w(duplicate question invalid wontfix),
max_issues: nil,
simple_list: false,
verbose: true,
merge_prefix: '**Merged pull requests:**',
issue_prefix: '**Closed issues:**',
bug_prefix: '**Fixed bugs:**',
enhancement_prefix: '**Implemented enhancements:**',
author: true,
filter_issues_by_milestone: true,
max_issues: nil,
compare_link: true,
unreleased: true,
unreleased_label: 'Unreleased',
branch: 'origin'
}
@ -38,25 +41,25 @@ module GitHubChangelogGenerator
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub') do |last|
options[:project] = last
end
opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests per hour your GitHub token required. You can generate it here: https://github.com/settings/tokens/new') do |last|
opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests per hour your GitHub token is required. You can generate it at: https://github.com/settings/tokens/new') do |last|
options[:token] = last
end
opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %d/%m/%y') do |last|
options[:format] = last
opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %Y-%m-%d') do |last|
options[:dateformat] = last
end
opts.on('-o', '--output [NAME]', 'Output file. Default is CHANGELOG.md') do |last|
options[:output] = last
end
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
opts.on('--[no-]issues', 'Include closed issues in changelog. Default is true') do |v|
options[:issues] = v
end
opts.on('--[no-]issues-wo-labels', 'Include closed issues without labels to changelog. Default is true') do |v|
opts.on('--[no-]issues-wo-labels', 'Include closed issues without labels in changelog. Default is true') do |v|
options[:add_issues_wo_labels] = v
end
opts.on('--[no-]pr-wo-labels', 'Include pull requests without labels to changelog. Default is true') do |v|
opts.on('--[no-]pr-wo-labels', 'Include pull requests without labels in changelog. Default is true') do |v|
options[:add_pr_wo_labels] = v
end
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
opts.on('--[no-]pull-requests', 'Include pull-requests in changelog. Default is true') do |v|
options[:pulls] = v
end
opts.on('--[no-]filter-by-milestone', 'Use milestone to detect when issue was resolved. Default is true') do |last|
@ -77,10 +80,10 @@ module GitHubChangelogGenerator
opts.on('--[no-]compare-link', 'Include compare link (Full Changelog) between older version and newer version. Default is true') do |v|
options[:compare_link] = v
end
opts.on('--include-labels x,y,z', Array, 'Issues only with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list|
opts.on('--include-labels x,y,z', Array, 'Only issues with the specified labels will be included in the changelog. Default is \'bug,enhancement\'') do |list|
options[:include_labels] = list
end
opts.on('--exclude-labels x,y,z', Array, 'Issues with that labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
opts.on('--exclude-labels x,y,z', Array, 'Issues with the specified labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
options[:exclude_labels] = list
end
opts.on('--max-issues [NUMBER]', Integer, 'Max number of issues to fetch from GitHub. Default is unlimited') do |max|