Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub::check_runs. #6455

Merged
merged 1 commit into from Sep 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion Library/Homebrew/utils/github.rb
Expand Up @@ -163,7 +163,8 @@ def open_api(url, data: nil, request_method: nil, scopes: [].freeze)
# This is a no-op if the user is opting out of using the GitHub API.
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]

args = ["--header", "application/vnd.github.v3+json", "--write-out", "\n%{http_code}"]
args = ["--header", "Accept: application/vnd.github.v3+json", "--write-out", "\n%{http_code}"]
args += ["--header", "Accept: application/vnd.github.antiope-preview+json"]

token, username = api_credentials
case api_credentials_type
Expand Down Expand Up @@ -261,6 +262,15 @@ def raise_api_error(output, errors, http_code, headers, scopes)
end
end

def check_runs(repo: nil, commit: nil, pr: nil)
if pr
repo = pr.fetch("base").fetch("repo").fetch("full_name")
commit = pr.fetch("head").fetch("sha")
end

open_api(url_to("repos", repo, "commits", commit, "check-runs"))
end

def search_issues(query, **qualifiers)
search("issues", query, **qualifiers)
end
Expand Down