Skip to content

Commit

Permalink
Merge pull request #1234 from octokit/statuses
Browse files Browse the repository at this point in the history
Generate statuses client
  • Loading branch information
Heather Harvey authored Apr 7, 2020
2 parents 791aec6 + c1ddde0 commit 0863ecb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 58 deletions.
47 changes: 13 additions & 34 deletions lib/octokit/client/statuses.rb
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
# frozen_string_literal: true

module Octokit
class Client

# Methods for the Commit Statuses API
# Methods for the Statuses API
#
# @see https://developer.github.com/v3/repos/statuses/
module Statuses

# List all statuses for a given commit
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @param sha [String] The SHA1 for the commit
# @return [Array<Sawyer::Resource>] A list of statuses
# @see https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
def statuses(repo, sha, options = {})
paginate "#{Repository.path repo}/statuses/#{sha}", options
end
alias :list_statuses :statuses

# Get the combined status for a ref
#
# @param repo [Integer, String, Repository, Hash] a GitHub repository
# @param ref [String] A Sha or Ref to fetch the status of
# @return [Sawyer::Resource] The combined status for the commit
# @see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
def combined_status(repo, ref, options = {})
get "#{Repository.path repo}/commits/#{ref}/status", options
end
alias :status :combined_status

# Create status for a commit
# Create a status
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @param sha [String] The SHA1 for the commit
# @param state [String] The state: pending, success, failure, error
# @option options [String] :context A context to differentiate this status from others
# @option options [String] :target_url A link to more details about this status
# @option options [String] :description A short human-readable description of this status
# @return [Sawyer::Resource] A status
# @param sha [String] The sha of the status
# @param state [String] The state of the status. Can be one of error, failure, pending, or success.
# @option options [String] :target_url The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status. For example, if your continuous integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA: http://ci.example.com/user/repo/build/sha
# @option options [String] :description A short description of the status.
# @option options [String] :context A string label to differentiate this status from the status of other systems.
# @return [Sawyer::Resource] The new status
# @see https://developer.github.com/v3/repos/statuses/#create-a-status
def create_status(repo, sha, state, options = {})
options = options.merge(:state => state)
post "#{Repository.path repo}/statuses/#{sha}", options
opts = options.dup
opts[:state] = state.to_s.downcase
post "#{Repository.path repo}/statuses/#{sha}", opts
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions lib/openapi_client_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ def paginate?
def singular?
return false if paginate?
return false if definition.responses.first.content &&
definition.responses.first.content["application/json"] &&
definition.responses.first.content["application/json"]["schema"]["type"] == "array"
definition.responses.first.content.dig("application/json", "schema", "type") == "array"
true
end

Expand Down Expand Up @@ -406,7 +405,7 @@ def self.at(definition, parameterizer: OpenAPIClientGenerator::Endpoint::Positio
def self.resource_for_path(path)
path_segments = path.split("/").reject{ |segment| segment == "" }

supported_resources = %w(deployments pages hooks releases labels milestones issues reactions projects gists events checks contents downloads readme notifications pulls stats)
supported_resources = %w(deployments pages hooks releases labels milestones issues reactions projects gists events checks contents downloads readme notifications pulls stats statuses)
resource = case path_segments.first
when "orgs", "users"
path_segments[2]
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0863ecb

Please sign in to comment.