Merge pull request #315 from skywinder/feature/repair-recognizing-user-and-project
Parser: avoid Ruby exit, to make Rake tasks work
This commit is contained in:
commit
3a784b16d6
|
@ -9,14 +9,14 @@ Gem::Specification.new do |spec|
|
||||||
spec.version = GitHubChangelogGenerator::VERSION
|
spec.version = GitHubChangelogGenerator::VERSION
|
||||||
spec.default_executable = "github_changelog_generator"
|
spec.default_executable = "github_changelog_generator"
|
||||||
|
|
||||||
spec.required_ruby_version = ">= 1.9.3"
|
spec.required_ruby_version = ">= 1.9.3"
|
||||||
spec.authors = ["Petr Korolev"]
|
spec.authors = ["Petr Korolev"]
|
||||||
spec.email = "sky4winder+github_changelog_generator@gmail.com"
|
spec.email = "sky4winder+github_changelog_generator@gmail.com"
|
||||||
spec.date = `date +"%Y-%m-%d"`.strip!
|
spec.date = `date +"%Y-%m-%d"`.strip!
|
||||||
spec.summary = "Script, that automatically generate changelog from your tags, issues, labels and pull requests."
|
spec.summary = "Script, that automatically generate changelog from your tags, issues, labels and pull requests."
|
||||||
spec.description = "Changelog generation has never been so easy. Fully automate changelog generation - this gem generate change log file based on tags, issues and merged pull requests from Github issue tracker."
|
spec.description = "Changelog generation has never been so easy. Fully automate changelog generation - this gem generate change log file based on tags, issues and merged pull requests from Github issue tracker."
|
||||||
spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator"
|
spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator"
|
||||||
spec.license = "MIT"
|
spec.license = "MIT"
|
||||||
|
|
||||||
spec.files = `git ls-files -z`.split("\x0")
|
spec.files = `git ls-files -z`.split("\x0")
|
||||||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
||||||
|
|
|
@ -217,7 +217,7 @@ module GitHubChangelogGenerator
|
||||||
#
|
#
|
||||||
# @param [String] output of git remote command
|
# @param [String] output of git remote command
|
||||||
# @return [Array] user and project
|
# @return [Array] user and project
|
||||||
def self.user_project_from_option(arg0, arg1, github_site = nil)
|
def self.user_project_from_option(arg0, arg1, github_site)
|
||||||
user = nil
|
user = nil
|
||||||
project = nil
|
project = nil
|
||||||
github_site ||= "github.com"
|
github_site ||= "github.com"
|
||||||
|
@ -230,10 +230,10 @@ module GitHubChangelogGenerator
|
||||||
param = match[2].nil?
|
param = match[2].nil?
|
||||||
rescue
|
rescue
|
||||||
puts "Can't detect user and name from first parameter: '#{arg0}' -> exit'"
|
puts "Can't detect user and name from first parameter: '#{arg0}' -> exit'"
|
||||||
exit
|
return
|
||||||
end
|
end
|
||||||
if param
|
if param
|
||||||
exit
|
return
|
||||||
else
|
else
|
||||||
user = match[1]
|
user = match[1]
|
||||||
project = match[2]
|
project = match[2]
|
||||||
|
@ -276,9 +276,4 @@ module GitHubChangelogGenerator
|
||||||
[user, project]
|
[user, project]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if __FILE__ == $PROGRAM_NAME
|
|
||||||
remote = "invalid reference to project"
|
|
||||||
p user_project_from_option(ARGV[0], ARGV[1], remote)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,16 +28,16 @@ describe GitHubChangelogGenerator::Parser do
|
||||||
end
|
end
|
||||||
describe ".user_project_from_option" do
|
describe ".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 return nil") { expect(GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil, nil)).to be_nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when option is valid" do
|
context "when option is valid" do
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil) }
|
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, nil) }
|
||||||
it { is_expected.to be_a(Array) }
|
it { is_expected.to be_a(Array) }
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
||||||
end
|
end
|
||||||
context "when option nil" do
|
context "when option nil" do
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option(nil, nil) }
|
subject { GitHubChangelogGenerator::Parser.user_project_from_option(nil, nil, nil) }
|
||||||
it { is_expected.to be_a(Array) }
|
it { is_expected.to be_a(Array) }
|
||||||
it { is_expected.to match_array([nil, nil]) }
|
it { is_expected.to match_array([nil, nil]) }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user