class Dependabot::Clients::BitbucketWithRetries
def self.for_bitbucket_dot_org(credentials:)
def self.for_bitbucket_dot_org(credentials:) credential = credentials .select { |cred| cred["type"] == "git_source" } .find { |cred| cred["host"] == "bitbucket.org" } new(credentials: credential) end
def initialize(credentials:, max_retries: 3)
def initialize(credentials:, max_retries: 3) @max_retries = T.let(max_retries || 3, Integer) @client = T.let(Bitbucket.new(credentials: credentials), Dependabot::Clients::Bitbucket) end
def method_missing(method_name, *args, &block)
def method_missing(method_name, *args, &block) retry_connection_failures do if @client.respond_to?(method_name) mutatable_args = args.map(&:dup) T.unsafe(@client).public_send(method_name, *mutatable_args, &block) else super end end end
def respond_to_missing?(method_name, include_private = false)
def respond_to_missing?(method_name, include_private = false) @client.respond_to?(method_name) || super end
def retry_connection_failures(&_blk)
def retry_connection_failures(&_blk) retry_attempt = 0 begin yield rescue *RETRYABLE_ERRORS retry_attempt += 1 retry_attempt <= @max_retries ? retry : raise end end