lib/octopolo/pull_request_merger.rb in octopolo-0.1.0 vs lib/octopolo/pull_request_merger.rb in octopolo-0.1.1

- old
+ new

@@ -1,8 +1,8 @@ require_relative "scripts" require_relative "git" -require_relative "github/pull_request" +require_relative "github" require_relative "dated_branch_creator" module Octopolo class PullRequestMerger include ConfigWrapper @@ -40,18 +40,24 @@ git.if_clean do check_out_branch merge_pull_request comment_about_merge end - rescue GitHub::PullRequest::NotFound - cli.say "Unable to find pull request #{pull_request_id}. Please retry with a valid ID." - rescue Git::MergeFailed - cli.say "Merge failed. Please identify the source of this merge conflict resolve this conflict in your pull request's branch. NOTE: Merge conflicts resolved in the #{branch_type} branch are NOT used when deploying." - rescue Git::CheckoutFailed - cli.say "Checkout of #{branch_to_merge_into} failed. Please contact Infrastructure to determine the cause." - rescue GitHub::PullRequest::CommentFailed - cli.say "Unable to write comment. Please navigate to #{pull_request.url} and add the comment, '#{comment_body}'" + rescue => e + case e + when GitHub::PullRequest::NotFound + cli.say "Unable to find pull request #{pull_request_id}. Please retry with a valid ID." + when Git::MergeFailed + cli.say "Merge failed. Please identify the source of this merge conflict resolve this conflict in your pull request's branch. NOTE: Merge conflicts resolved in the #{branch_type} branch are NOT used when deploying." + when Git::CheckoutFailed + cli.say "Checkout of #{branch_to_merge_into} failed. Please contact Infrastructure to determine the cause." + when GitHub::PullRequest::CommentFailed + cli.say "Unable to write comment. Please navigate to #{pull_request.url} and add the comment, '#{comment_body}'" + else + cli.say "An uknown error occured: #{e.class.to_s}" + end + false end # Public: Check out the branch def check_out_branch git.check_out branch_to_merge_into @@ -94,6 +100,5 @@ def branch_to_merge_into @branch_to_merge_into ||= git.latest_branch_for(branch_type) end end end -