Compare commits

..

3 Commits

Author SHA1 Message Date
Petr Korolev
d4664e389d add tests 2015-05-25 18:04:32 +03:00
Petr Korolev
0e352886ea fix #172 2015-05-25 17:16:35 +03:00
Petr Korolev
01e30d1132 fix log 2015-05-25 17:01:10 +03:00
8 changed files with 55 additions and 118 deletions

View File

@@ -6,11 +6,3 @@ Metrics/LineLength:
#http://viget.com/extend/just-use-double-quoted-ruby-strings #http://viget.com/extend/just-use-double-quoted-ruby-strings
Style/StringLiterals: Style/StringLiterals:
EnforcedStyle: double_quotes EnforcedStyle: double_quotes
# Configuration parameters: CountComments.
Metrics/ClassLength:
Enabled: false
# Configuration parameters: CountComments.
Metrics/MethodLength:
Enabled: false

View File

@@ -1,5 +1,5 @@
# This configuration was generated by `rubocop --auto-gen-config` # This configuration was generated by `rubocop --auto-gen-config`
# on 2015-05-26 16:00:55 +0300 using RuboCop version 0.31.0. # on 2015-05-25 17:16:04 +0300 using RuboCop version 0.31.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
@@ -7,12 +7,22 @@
# Offense count: 14 # Offense count: 14
Metrics/AbcSize: Metrics/AbcSize:
Max: 59 Max: 57
# Offense count: 4
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 182
# Offense count: 1 # Offense count: 1
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 7 Max: 7
# Offense count: 22
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 84
# Offense count: 1 # Offense count: 1
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 8 Max: 8

View File

@@ -82,35 +82,30 @@ As output you will get `CHANGELOG.md` file with pretty *Markdown-formatted* chan
### Params ### Params
Type `github_changelog_generator --help` for detailed usage. Type `github_changelog_generator --help` for detailed usage.
Usage: github_changelog_generator [options] Usage: changelog_generator [options]
-u, --user [USER] Username of the owner of target GitHub repo -u, --user [USER] Username of the owner of target GitHub repo
-p, --project [PROJECT] Name of project on GitHub -p, --project [PROJECT] Name of project on GitHub
-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 -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
-f, --date-format [FORMAT] Date format. Default is %Y-%m-%d -f, --date-format [FORMAT] Date format. Default is %d/%m/%y
-o, --output [NAME] Output file. Default is CHANGELOG.md -o, --output [NAME] Output file. Default is CHANGELOG.md
--[no-]issues Include closed issues in changelog. Default is true --[no-]verbose Run verbosely. Default is true
--[no-]issues-wo-labels Include closed issues without labels in changelog. Default is true --[no-]issues Include closed issues to changelog. Default is true
--[no-]pr-wo-labels Include pull requests without labels in changelog. Default is true --[no-]issues-wo-labels Include closed issues without labels to changelog. Default is true
--[no-]pull-requests Include pull-requests in changelog. Default is true --[no-]pr-wo-labels Include pull requests without labels to changelog. Default is true
--[no-]filter-by-milestone Use milestone to detect when issue was resolved. Default is true --[no-]pull-requests Include pull-requests to changelog. Default is true
--[no-]author Add author of pull-request in the end. Default is true --[no-]filter-by-milestone Use milestone to detect when issue was resolved. Default is true
--unreleased-only Generate log from unreleased closed issues only. --[no-]author Add author of pull-request in the end. Default is true
--[no-]unreleased Add to log unreleased closed issues. Default is true --unreleased-only Generate log from unreleased closed issues only.
--unreleased-label [label] Add to log unreleased closed issues. Default is true --[no-]unreleased Add to log unreleased closed issues. Default is true
--[no-]compare-link Include compare link (Full Changelog) between older version and newer version. Default is true --[no-]compare-link Include compare link between older version and newer version. Default is true
--include-labels x,y,z Only issues with the specified labels will be included in the changelog. Default is 'bug,enhancement' --include-labels x,y,z Issues only with that labels will be included to changelog. Default is 'bug,enhancement'
--exclude-labels x,y,z Issues with the specified labels will be always excluded from changelog. Default is 'duplicate,question,invalid,wontfix' --exclude-labels x,y,z Issues with that labels will be always excluded from changelog. Default is 'duplicate,question,invalid,wontfix'
--between-tags x,y,z Change log will be filled only between specified tags --max-issues [NUMBER] Max number of issues to fetch from GitHub. Default is unlimited.
--exclude-tags x,y,z Change log will be exclude specified tags --github-site [URL] The Enterprise Github site on which your project is hosted.
--max-issues [NUMBER] Max number of issues to fetch from GitHub. Default is unlimited --github-api [URL] The enterprise endpoint to use for your Github API.
--github-site [URL] The Enterprise Github site on which your project is hosted. --future-release [RELEASE-VERSION] Put the unreleased changes in the specified release number.
--github-api [URL] The enterprise endpoint to use for your Github API. -v, --version Print version number
--simple-list Create simple list from issues and pull requests. Default is false. -h, --help Displays Help
--future-release [RELEASE-VERSION]
Put the unreleased changes in the specified release number.
--[no-]verbose Run verbosely. Default is true
-v, --version Print version number
-h, --help Displays Help
### GitHub token ### GitHub token

View File

@@ -37,11 +37,7 @@ module GitHubChangelogGenerator
# #
# @return [Array] # @return [Array]
def get_filtered_tags(all_tags) def get_filtered_tags(all_tags)
filtered_tags = filter_between_tags(all_tags) all_tags = all_tags
filter_excluded_tags(filtered_tags)
end
def filter_between_tags(all_tags)
filtered_tags = all_tags filtered_tags = all_tags
if @options[:between_tags] if @options[:between_tags]
@options[:between_tags].each do |tag| @options[:between_tags].each do |tag|
@@ -53,18 +49,5 @@ module GitHubChangelogGenerator
end end
filtered_tags filtered_tags
end end
def filter_excluded_tags(all_tags)
filtered_tags = all_tags
if @options[:exclude_tags]
@options[:exclude_tags].each do |tag|
unless all_tags.include? tag
puts "Warning: can't find tag #{tag}, specified with --between-tags option.".yellow
end
end
filtered_tags = all_tags.reject { |tag| @options[:exclude_tags].include? tag }
end
filtered_tags
end
end end
end end

View File

@@ -84,12 +84,9 @@ module GitHubChangelogGenerator
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| 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 options[:exclude_labels] = list
end end
opts.on("--between-tags x,y,z", Array, "Change log will be filled only between specified tags") do |list| opts.on("--between-tags x,y,z", Array, "Change log will be filed only between specified tags") do |list|
options[:between_tags] = list options[:between_tags] = list
end end
opts.on("--exclude-tags x,y,z", Array, "Change log will be exclude specified tags") do |list|
options[:exclude_tags] = list
end
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max| opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
options[:max_issues] = max options[:max_issues] = max
end end

View File

@@ -1,3 +1,3 @@
module GitHubChangelogGenerator module GitHubChangelogGenerator
VERSION = "1.5.0" VERSION = "1.4.1"
end end

View File

@@ -1,69 +1,29 @@
describe GitHubChangelogGenerator::Generator do describe GitHubChangelogGenerator::Generator do
describe "#filter_between_tags" do describe "#get_filtered_tags" do
before(:all) do
@generator = GitHubChangelogGenerator::Generator.new
end
context "when between_tags nil" do context "when between_tags nil" do
before do # before(:each) do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: nil) # @generator.options = {}
end # end
subject { @generator.get_filtered_tags(%w(1 2 3)) }
subject do
@generator.get_filtered_tags(%w(1 2 3))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1 2 3)) }
end
context "when between_tags same as input array" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3))
end
subject do
@generator.get_filtered_tags(%w(1 2 3))
end
it { is_expected.to be_a(Array) } it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1 2 3)) } it { is_expected.to match_array(%w(1 2 3)) }
end end
context "when between_tags filled with correct values" do context "when between_tags 1" do
before do # before(:each) do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2)) # @generator.options = {between_tags: ["1"]}
end # end
subject do
@generator.get_filtered_tags(%w(1 2 3))
end
it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1 2)) }
end
context "when between_tags filled with invalid values" do
before do
@generator = GitHubChangelogGenerator::Generator.new(between_tags: %w(1 q w))
end
subject do subject do
@generator.instance_variable_set("@options", between_tags: ["1"])
@generator.get_filtered_tags(%w(1 2 3)) @generator.get_filtered_tags(%w(1 2 3))
end end
it { is_expected.to be_a(Array) } it { is_expected.to be_a(Array) }
it { is_expected.to match_array(%w(1)) } it { is_expected.to match_array(%w(1)) }
end end
end end
describe "#get_filtered_tags" do
subject { generator.get_filtered_tags(%w(1 2 3 4 5)) }
# before { generator.get_filtered_tags(%w(1 2 3 4 5)) }
context "with excluded and between tags" do
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3), exclude_tags: %w(2)) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(%w(1 3)) }
end
end
describe "#filter_excluded_tags" do
subject { generator.filter_excluded_tags(%w(1 2 3)) }
context "with valid excluded tags" do
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(3)) }
it { is_expected.to be_a Array }
it { is_expected.to match_array(%w(1 2)) }
end
end
end end

View File

@@ -1,5 +1,5 @@
describe GitHubChangelogGenerator::Parser do describe GitHubChangelogGenerator::Parser do
describe ".user_project_from_remote" do describe "#self.user_project_from_remote" do
context "when remote is 1" do context "when remote is 1" do
subject { GitHubChangelogGenerator::Parser.user_project_from_remote("origin https://github.com/skywinder/ActionSheetPicker-3.0 (fetch)") } subject { GitHubChangelogGenerator::Parser.user_project_from_remote("origin https://github.com/skywinder/ActionSheetPicker-3.0 (fetch)") }
it { is_expected.to be_a(Array) } it { is_expected.to be_a(Array) }
@@ -26,7 +26,7 @@ describe GitHubChangelogGenerator::Parser do
it { is_expected.to match_array([nil, nil]) } it { is_expected.to match_array([nil, nil]) }
end end
end end
describe ".user_project_from_option" do describe "#self.user_project_from_option" do
# context "when option is invalid" do # context "when option is invalid" do
# it("should exit") { expect { GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil) }.to raise_error(SystemExit) } # it("should exit") { expect { GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil) }.to raise_error(SystemExit) }
# end # end