class Travis::Tools::Github
def basic_auth(user, password, die = true, otp = nil, &block)
def basic_auth(user, password, die = true, otp = nil, &block) opt = { :username => user, :password => password } opt[:headers] = { "X-GitHub-OTP" => otp } if otp yield GH.with(opt) rescue GH::Error => error if error.info[:response_status] == 401 and error.info[:response_headers]['x-github-otp'].to_s =~ /required/ otp = ask_otp.arity == 0 ? ask_otp.call : ask_otp.call(user) basic_auth(user, password, die, otp, &block) elsif die raise gh_error(error) end end