Skip to content

Commit

Permalink
adding PullRequestUpdateFailed error in azure pr updater class
Browse files Browse the repository at this point in the history
  • Loading branch information
milind009 committed Apr 15, 2021
1 parent 46343ee commit 08d13b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
9 changes: 0 additions & 9 deletions common/lib/dependabot/errors.rb
Expand Up @@ -71,15 +71,6 @@ def initialize(source, msg = nil)
end
end

class PullRequestUpdateFailed < DependabotError
attr_reader :pull_request_id

def initialize(pull_request_id, msg = nil)
@pull_request_id = pull_request_id
super(msg)
end
end

#####################
# File level errors #
#####################
Expand Down
7 changes: 3 additions & 4 deletions common/lib/dependabot/pull_request_updater/azure.rb
Expand Up @@ -6,6 +6,8 @@
module Dependabot
class PullRequestUpdater
class Azure
class PullRequestUpdateFailed < Dependabot::DependabotError; end

OBJECT_ID_FOR_BRANCH_DELETE = "0000000000000000000000000000000000000000"

attr_reader :source, :files, :base_commit, :old_commit, :credentials,
Expand Down Expand Up @@ -59,10 +61,7 @@ def update_source_branch
# 3) Delete temp branch
update_branch(temp_branch_name, new_commit, OBJECT_ID_FOR_BRANCH_DELETE)

unless response.fetch("success", false)
raise Dependabot::PullRequestUpdateFailed.new(pull_request_number,
response.fetch("customMessage", nil))
end
raise PullRequestUpdateFailed, response.fetch("customMessage", nil) unless response.fetch("success", false)
end

def pull_request
Expand Down
2 changes: 1 addition & 1 deletion common/spec/dependabot/pull_request_updater/azure_spec.rb
Expand Up @@ -176,7 +176,7 @@
stub_request(:post, branch_update_url).
to_return(status: 200, body: fixture("azure", "update_ref_failed.json"))

expect { updater.update }.to raise_error(Dependabot::PullRequestUpdateFailed)
expect { updater.update }.to raise_error(Dependabot::PullRequestUpdater::Azure::PullRequestUpdateFailed)
end
end
end
Expand Down

0 comments on commit 08d13b7

Please sign in to comment.