Skip to content

Commit

Permalink
Reduce indentation (reduce visual complexity)
Browse files Browse the repository at this point in the history
  • Loading branch information
bittner committed Aug 11, 2020
1 parent d441ca4 commit c948011
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions lib/modulesync/pr/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c948011

Please sign in to comment.