Check for exception

This commit is contained in:
Petr Korolev 2015-02-06 16:36:52 +02:00
parent 82d8c72a4d
commit 69e3b17d8b

View File

@ -72,15 +72,23 @@ module GitHubChangelogGenerator
if ARGV[0] && !ARGV[1] if ARGV[0] && !ARGV[1]
github_site = options[:github_site] ? options[:github_site] : 'github.com' github_site = options[:github_site] ? options[:github_site] : 'github.com'
# this match should parse https://github.com/skywinder/Github-Changelog-Generator and skywinder/Github-Changelog-Generator to user and name # this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0]) match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0])
if match[2].nil? begin
param = match[2].nil?
rescue
puts "Can't detect user and name from first parameter: '#{ARGV[0]}' -> exit'"
exit
end
if param
exit exit
else else
options[:user] = match[1] options[:user] = match[1]
options[:project]= match[2] options[:project]= match[2]
end end
end end
if !options[:user] && !options[:project] if !options[:user] && !options[:project]