From c948011845b2f363f5d7d1f3de0fbdc1d342928c Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Tue, 11 Aug 2020 09:36:26 +0200 Subject: [PATCH] Reduce indentation (reduce visual complexity) --- lib/modulesync/pr/gitlab.rb | 39 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/modulesync/pr/gitlab.rb b/lib/modulesync/pr/gitlab.rb index 4a7b067c..2bb61649 100644 --- a/lib/modulesync/pr/gitlab.rb +++ b/lib/modulesync/pr/gitlab.rb @@ -23,26 +23,27 @@ def manage(namespace, module_name, options) $stdout.puts \ "Using no-op. Would submit MR '#{options[:pr_title]}' to #{repo_path} " \ "- merges #{options[:branch]} into #{target_branch}" + return + end + + merge_requests = @api.merge_requests(repo_path, + :state => 'opened', + :source_branch => head, + :target_branch => target_branch) + if merge_requests.empty? + mr_labels = ModuleSync::Util.parse_list(options[:pr_labels]) + mr = @api.create_merge_request(repo_path, options[:pr_title], + :source_branch => options[:branch], + :target_branch => target_branch, + :labels => mr_labels) + $stdout.puts \ + "Submitted MR '#{options[:pr_title]}' to #{repo_path} " \ + "- merges #{options[:branch]} into #{target_branch}" + return if mr_labels.empty? + $stdout.puts "Attached the following labels to MR #{mr.iid}: #{mr_labels.join(', ')}" else - merge_requests = @api.merge_requests(repo_path, - :state => 'opened', - :source_branch => head, - :target_branch => target_branch) - if merge_requests.empty? - mr_labels = ModuleSync::Util.parse_list(options[:pr_labels]) - mr = @api.create_merge_request(repo_path, options[:pr_title], - :source_branch => options[:branch], - :target_branch => target_branch, - :labels => mr_labels) - $stdout.puts \ - "Submitted MR '#{options[:pr_title]}' to #{repo_path} " \ - "- merges #{options[:branch]} into #{target_branch}" - return if mr_labels.empty? - $stdout.puts "Attached the following labels to MR #{mr.iid}: #{mr_labels.join(', ')}" - else - # Skip creating the MR if it exists already. - $stdout.puts "Skipped! #{merge_requests.length} MRs found for branch #{options[:branch]}" - end + # Skip creating the MR if it exists already. + $stdout.puts "Skipped! #{merge_requests.length} MRs found for branch #{options[:branch]}" end end end