Merge branch 'hotfix/update-changelog' into develop

This commit is contained in:
Petr Korolev 2016-04-01 13:33:21 +03:00
commit 0dddc4a44c
5 changed files with 51 additions and 12 deletions

View File

@ -1,5 +1,17 @@
# Change Log
## [1.12.0](https://github.com/skywinder/github-changelog-generator/tree/1.12.0) (2016-04-01)
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.8...1.12.0)
**Closed issues:**
- .github\_changelog\_generator config file is not consistent with the internal options hash [\#312](https://github.com/skywinder/github-changelog-generator/issues/312)
- Feature request: YAML front matter [\#276](https://github.com/skywinder/github-changelog-generator/issues/276)
**Merged pull requests:**
- Added tag exclusion with a filter \(string or regex\) [\#320](https://github.com/skywinder/github-changelog-generator/pull/320) ([soundstep](https://github.com/soundstep))
## [1.11.8](https://github.com/skywinder/github-changelog-generator/tree/1.11.8) (2016-03-22)
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.7...1.11.8)

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
github_changelog_generator (1.11.8)
github_changelog_generator (1.12.0)
bundler (>= 1.7)
colorize (~> 0.7)
github_api (~> 0.12)

View File

@ -129,26 +129,34 @@ module GitHubChangelogGenerator
end
# @param [Array] all_tags all tags
# @return [Array] filtered tags according :exclude_tags option
# @return [Array] filtered tags according :exclude_tags or :exclude_tags_regex option
def filter_excluded_tags(all_tags)
return all_tags unless @options[:exclude_tags]
apply_exclude_tags(all_tags)
if @options[:exclude_tags]
apply_exclude_tags(all_tags)
elsif @options[:exclude_tags_regex]
apply_exclude_tags_regex(all_tags)
else
all_tags
end
end
private
def apply_exclude_tags(all_tags)
if @options[:exclude_tags].is_a?(Regexp)
filter_tags_with_regex(all_tags)
filter_tags_with_regex(all_tags, @options[:exclude_tags])
else
filter_exact_tags(all_tags)
end
end
def filter_tags_with_regex(all_tags)
def apply_exclude_tags_regex(all_tags)
filter_tags_with_regex(all_tags, Regexp.new(@options[:exclude_tags_regex]))
end
def filter_tags_with_regex(all_tags, regex)
warn_if_nonmatching_regex(all_tags)
all_tags.reject { |tag| @options[:exclude_tags] =~ tag.name }
all_tags.reject { |tag| regex =~ tag.name }
end
def filter_exact_tags(all_tags)

View File

@ -122,6 +122,9 @@ module GitHubChangelogGenerator
opts.on("--exclude-tags x,y,z", Array, "Change log will exclude specified tags") do |list|
options[:exclude_tags] = list
end
opts.on("--exclude-tags-regex [REGEX]", "Apply a regular expression on tag names so that they can be excluded, for example: --exclude-tags-regex \".*\+\d{1,}\" ") do |last|
options[:exclude_tags_regex] = last
end
opts.on("--since-tag x", "Change log will start after specified tag") do |v|
options[:since_tag] = v
end

View File

@ -76,31 +76,47 @@ describe GitHubChangelogGenerator::Generator do
describe "#filter_excluded_tags" do
subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) }
context "with valid excluded tags" do
context "with matching string" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(3)) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2))) }
end
context "with invalid excluded tags" do
context "with non-matching string" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(invalid tags)) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
end
context "with regex exclude_tags" do
context "with matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[23]/) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
end
context "with non-matching regex in exclude_tags" do
context "with non-matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: /[abc]/) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
end
end
describe "#filter_excluded_tags_regex" do
subject { generator.filter_excluded_tags(tags_mash_from_strings(%w(1 2 3))) }
context "with matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: '[23]') }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_mash_from_strings(%w(1))) }
end
context "with non-matching regex" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags_regex: '[45]') }
it { is_expected.to be_a Array }
it { is_expected.to match_array(tags_mash_from_strings(%w(1 2 3))) }
end
end
describe "#filter_since_tag" do
context "with filled array" do
subject { generator.filter_since_tag(tags_mash_from_strings(%w(1 2 3))) }