diff --git a/lib/modulesync.rb b/lib/modulesync.rb index d3dd5ee2..196ca346 100644 --- a/lib/modulesync.rb +++ b/lib/modulesync.rb @@ -132,32 +132,25 @@ def self.manage_module(puppet_module, module_files, module_options, defaults, op if options[:noop] Git.update_noop(git_repo, options) elsif !options[:offline] - if options[:pr] - manage_pr_or_mr(git_repo, files_to_manage, namespace, module_name, options) - else - Git.update(git_repo, files_to_manage, options) - end - end - end + pushed = Git.update(git_repo, files_to_manage, options) - def self.manage_pr_or_mr(git_repo, files_to_manage, namespace, module_name, options) - unless options[:branch] - $stderr.puts 'A branch must be specified with --branch to use --pr!' - return nil + if pushed && options[:pr] + @pr.manage(namespace, module_name, options) + end end - # Git.update() returns a boolean: true if files were pushed, false if not. - pushed = Git.update(git_repo, files_to_manage, options) - - # If there's nothing pushed, we're done - return nil unless pushed - - @pr.manage(namespace, module_name, options) end def self.update(options) options = config_defaults.merge(options) defaults = Util.parse_config(File.join(options[:configs], CONF_FILE)) - @pr = get_pr_manager if options[:pr] + if options[:pr] + unless options[:branch] + $stderr.puts 'A branch must be specified with --branch to use --pr!' + raise + end + + @pr = get_pr_manager if options[:pr] + end local_template_dir = File.join(options[:configs], MODULE_FILES_DIR) local_files = find_template_files(local_template_dir)