Skip to content

Commit

Permalink
Merge pull request #537 from octokit/remove-deployments-preview-warning
Browse files Browse the repository at this point in the history
Remove Deployments API preview warnings
  • Loading branch information
pengwynn committed Dec 2, 2014
2 parents 702152a + c679388 commit e08a454
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions lib/octokit/client/deployments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ class Client
# @see https://developer.github.com/v3/repos/commits/deployments/
module Deployments

DEPLOYMENTS_PREVIEW_MEDIA_TYPE = "application/vnd.github.cannonball-preview+json".freeze

# List all deployments for a repository
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @return [Array<Sawyer::Resource>] A list of deployments
# @see https://developer.github.com/v3/repos/deployments/#list-deployments
def deployments(repo, options = {})
options = ensure_deployments_api_media_type(options)
get("#{Repository.path repo}/deployments", options)
end
alias :list_deployments :deployments
Expand All @@ -32,7 +29,6 @@ def deployments(repo, options = {})
# @return [Sawyer::Resource] A deployment
# @see https://developer.github.com/v3/repos/deployments/#create-a-deployment
def create_deployment(repo, ref, options = {})
options = ensure_deployments_api_media_type(options)
options[:ref] = ref
post("#{Repository.path repo}/deployments", options)
end
Expand All @@ -43,7 +39,6 @@ def create_deployment(repo, ref, options = {})
# @return [Array<Sawyer::Resource>] A list of deployment statuses
# @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
def deployment_statuses(deployment_url, options = {})
options = ensure_deployments_api_media_type(options)
deployment = get(deployment_url, :accept => options[:accept])
get(deployment.rels[:statuses].href, options)
end
Expand All @@ -56,30 +51,10 @@ def deployment_statuses(deployment_url, options = {})
# @return [Sawyer::Resource] A deployment status
# @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
def create_deployment_status(deployment_url, state, options = {})
options = ensure_deployments_api_media_type(options)
deployment = get(deployment_url, :accept => options[:accept])
options[:state] = state.to_s.downcase
post(deployment.rels[:statuses].href, options)
end

private

def ensure_deployments_api_media_type(options = {})
if options[:accept].nil?
options[:accept] = DEPLOYMENTS_PREVIEW_MEDIA_TYPE
warn_deployments_preview
end

options
end

def warn_deployments_preview
octokit_warn <<-EOS
WARNING: The preview version of the Deployments API is not yet suitable for production use.
You can avoid this message by supplying an appropriate media type in the 'Accept' request
header. See the blog post for details: http://git.io/o2XZRA
EOS
end
end
end
end

0 comments on commit e08a454

Please sign in to comment.