class CC::Service::GitHubPullRequests

Private Instance Methods

base_status_url(commit_sha) click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 98
def base_status_url(commit_sha)
  "#{config.base_url}/repos/#{github_slug}/statuses/#{commit_sha}"
end
github_login() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 54
def github_login
  @payload["github_login"]
end
github_slug() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 102
def github_slug
  @payload.fetch("github_slug")
end
github_user_id() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 58
def github_user_id
  @payload["github_user_id"]
end
report_status?() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 31
def report_status?
  if should_apply_rollout?
    rollout_allowed_by_username? || rollout_allowed_by_percentage?
  else
    true
  end
end
response_includes_repo_scope?(response) click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 106
def response_includes_repo_scope?(response)
  response.headers["x-oauth-scopes"] && response.headers["x-oauth-scopes"].split(/\s*,\s*/).include?("repo")
end
rollout_allowed_by_percentage?() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 49
def rollout_allowed_by_percentage?
  github_user_id.present? && config.rollout_percentage.present? &&
    github_user_id % 100 < config.rollout_percentage
end
rollout_allowed_by_username?() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 44
def rollout_allowed_by_username?
  github_login.present? && config.rollout_usernames.present? &&
    config.rollout_usernames.split(",").map(&:strip).include?(github_login)
end
setup_http() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 92
def setup_http
  http.headers["Content-Type"] = "application/json"
  http.headers["Authorization"] = "token #{config.oauth_token}"
  http.headers["User-Agent"] = "Code Climate"
end
should_apply_rollout?() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 39
def should_apply_rollout?
  (github_login.present? && config.rollout_usernames.present?) ||
    (github_user_id.present? && config.rollout_percentage.present?)
end
test_status_code() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 110
def test_status_code
  422
end
update_coverage_status_success() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 70
def update_coverage_status_success
  update_status("success", presenter.coverage_message, "#{config.context}/coverage")
end
update_status_error() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 78
def update_status_error
  update_status(
    "error",
    @payload["message"] || presenter.error_message,
  )
end
update_status_failure() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 74
def update_status_failure
  update_status("failure", presenter.success_message)
end
update_status_pending() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 85
def update_status_pending
  update_status(
    "pending",
    @payload["message"] || presenter.pending_message,
  )
end
update_status_skipped() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 62
def update_status_skipped
  update_status("success", presenter.skipped_message)
end
update_status_success() click to toggle source
# File lib/cc/services/github_pull_requests.rb, line 66
def update_status_success
  update_status("success", presenter.success_message)
end