diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 023a599..a3c2535 100755 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -61,7 +61,7 @@ module GitHubChangelogGenerator opts.on("-b", "--base [NAME]", "Optional base file to append generated changes to.") do |last| options[:base] = last end - opts.on("--bugs-label [LABEL]", "Setup custom label for bug-fixes section. Default is \"**Fixed bugs:**""") do |v| + opts.on("--bugs-label [LABEL]", "Setup custom label for bug-fixes section. Default is \"**Fixed bugs:**" "") do |v| options[:bug_prefix] = v end opts.on("--enhancement-label [LABEL]", "Setup custom label for enhancements section. Default is \"**Implemented enhancements:**\"") do |v| @@ -213,22 +213,29 @@ module GitHubChangelogGenerator # 2) in 2 params: repo name project def self.fetch_user_and_project(options) if options[:user].nil? || options[:project].nil? - user_and_project_from_git(options, ARGV[0], ARGV[1]) + user, project = user_and_project_from_git(options, ARGV[0], ARGV[1]) + options[:user] ||= user + options[:project] ||= project end end # Sets `:user` and `:project` in `options` from CLI arguments or `git remote` + # @param [String] arg0 first argument in cli + # @param [String] arg1 second argument in cli + # @return [Array] user and project, or nil if unsuccessful def self.user_and_project_from_git(options, arg0 = nil, arg1 = nil) - options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site]) - return if options[:user] && options[:project] - - if ENV["RUBYLIB"] =~ /ruby-debug-ide/ - options[:user] = "skywinder" - options[:project] = "changelog_test" - else - remote = `git config --get remote.#{options[:git_remote]}.url` - options[:user], options[:project] = user_project_from_remote(remote) + user, project = user_project_from_option(arg0, arg1, options[:github_site]) + unless user && project + if ENV["RUBYLIB"] =~ /ruby-debug-ide/ + user = "skywinder" + project = "changelog_test" + else + remote = `git config --get remote.#{options[:git_remote]}.url` + user, project = user_project_from_remote(remote) + end end + + [user, project] end # Returns GitHub username and project from CLI arguments