Merge branch 'master' into develop

This commit is contained in:
Petr Korolev 2016-02-25 11:56:17 +02:00
commit 827afcda02
7 changed files with 52 additions and 22 deletions

View File

@ -3,8 +3,6 @@ source "https://rubygems.org"
gemspec gemspec
group :test do group :test do
gem "rspec", "~>3.2"
gem "rubocop", "~>0.31"
gem "coveralls", "~>0.8", require: false gem "coveralls", "~>0.8", require: false
gem "simplecov", "~>0.10", require: false gem "simplecov", "~>0.10", require: false
gem "codeclimate-test-reporter", "~>0.4" gem "codeclimate-test-reporter", "~>0.4"

View File

@ -1,12 +1,14 @@
PATH PATH
remote: . remote: .
specs: specs:
github_changelog_generator (1.10.3) github_changelog_generator (1.10.4)
bundler (~> 1.7) bundler (>= 1.7)
colorize (~> 0.7) colorize (~> 0.7)
github_api (~> 0.12) github_api (~> 0.12)
overcommit (~> 0.31) overcommit (>= 0.31)
rake (~> 10.0) rake (>= 10.0)
rspec (>= 3.2)
rubocop (>= 0.31)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
@ -99,8 +101,6 @@ DEPENDENCIES
codeclimate-test-reporter (~> 0.4) codeclimate-test-reporter (~> 0.4)
coveralls (~> 0.8) coveralls (~> 0.8)
github_changelog_generator! github_changelog_generator!
rspec (~> 3.2)
rubocop (~> 0.31)
simplecov (~> 0.10) simplecov (~> 0.10)
BUNDLED WITH BUNDLED WITH

View File

@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"] spec.require_paths = ["lib"]
spec.add_runtime_dependency "rake", "~> 10.0" spec.add_runtime_dependency "rake", ">= 10.0"
spec.add_runtime_dependency "bundler", "~> 1.7" spec.add_runtime_dependency "bundler", ">= 1.7"
spec.add_runtime_dependency("github_api", ["~> 0.12"]) spec.add_runtime_dependency("github_api", ["~> 0.12"])
spec.add_runtime_dependency("colorize", ["~> 0.7"]) spec.add_runtime_dependency("colorize", ["~> 0.7"])
spec.add_runtime_dependency("overcommit", "~>0.31") spec.add_runtime_dependency("overcommit", ">= 0.31")
spec.add_runtime_dependency("rubocop", ">= 0.31")
spec.add_runtime_dependency("rspec", ">= 3.2")
end end

View File

@ -4,14 +4,13 @@ module GitHubChangelogGenerator
# @param [Array] issues # @param [Array] issues
# @return [Array] filtered array # @return [Array] filtered array
def exclude_issues_by_labels(issues) def exclude_issues_by_labels(issues)
unless @options[:exclude_labels].nil? return issues if !@options[:exclude_labels] || @options[:exclude_labels].empty?
issues = issues.select do |issue|
var = issue.labels.map(&:name) & @options[:exclude_labels] issues.reject do |issue|
!var.any? labels = issue.labels.map(&:name)
(labels & @options[:exclude_labels]).any?
end end
end end
issues
end
# @return [Array] filtered issues accourding milestone # @return [Array] filtered issues accourding milestone
def filter_by_milestone(filtered_issues, tag_name, all_issues) def filter_by_milestone(filtered_issues, tag_name, all_issues)

View File

@ -1,21 +1,24 @@
require 'pathname'
module GitHubChangelogGenerator module GitHubChangelogGenerator
ParserError = Class.new(StandardError) ParserError = Class.new(StandardError)
class ParserFile class ParserFile
FILENAME = ".github_changelog_generator"
def initialize(options) def initialize(options)
@options = options @options = options
end end
# Destructively change @options using data in configured options file.
def parse! def parse!
return unless File.exist?(file) file.each_line { |line| parse_line!(line) } if file.exist?
File.readlines(file).each { |line| parse_line!(line) }
end end
private private
def file def file
@file ||= File.expand_path(@options[:params_file] || ".github_changelog_generator") @file ||= Pathname(File.expand_path(@options[:params_file] || FILENAME))
end end
def parse_line!(line) def parse_line!(line)

View File

@ -1,3 +1,3 @@
module GitHubChangelogGenerator module GitHubChangelogGenerator
VERSION = "1.10.4" VERSION = "1.11.0"
end end

View File

@ -0,0 +1,28 @@
module GitHubChangelogGenerator
describe Generator do
context "#exclude_issues_by_labels" do
let(:label) { double("the-bad-label", name: "BAD") }
let(:issue) { double("the-issue-to-be-excluded", labels: [label]) }
let(:good_label) { double("a-good-label", name: "GOOD") }
let(:good_issue) { double("an-issue-to-be-kept", labels: [good_label]) }
let(:issues) { [issue, good_issue] }
subject(:generator) { described_class.new(exclude_labels: %w(BAD BOO)) }
it "removes issues with labels in the exclude_label list" do
result = generator.exclude_issues_by_labels(issues)
expect(result).to include(good_issue)
expect(result).not_to include(issue)
end
context "with no option given" do
subject(:generator) { described_class.new }
it "passes everything through when no option given" do
result = generator.exclude_issues_by_labels(issues)
expect(result).to eq(issues)
end
end
end
end
end