From 69e3b17d8b07525d197bd0115463713f2059702c Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Fri, 6 Feb 2015 16:36:52 +0200 Subject: [PATCH] Check for exception --- lib/github_changelog_generator/parser.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 1afc786..7f3acbc 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -72,15 +72,23 @@ module GitHubChangelogGenerator if ARGV[0] && !ARGV[1] 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]) - 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 else options[:user] = match[1] options[:project]= match[2] end + + end if !options[:user] && !options[:project]