module Octokit::Client::Refs

def create_ref(repo, ref, sha, options = {})

Other tags:
    Example: Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132 -

Other tags:
    See: https://developer.github.com/v3/git/refs/#create-a-reference -

Returns:
  • (Array) - The list of references, already containing the new one

Parameters:
  • sha (String) -- A SHA, e.g. 827efc6d56897b048c772eb4087f854f46256132
  • ref (String) -- The ref, e.g. tags/v0.0.3
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def create_ref(repo, ref, sha, options = {})
  ref = "refs/#{ref}" unless ref =~ %r{\Arefs/}
  parameters = {
    ref: ref,
    sha: sha
  }
  post "#{Repository.path repo}/git/refs", options.merge(parameters)
end

def delete_branch(repo, branch, options = {})

Other tags:
    Example: Delete uritemplate for sigmavirus24/github3.py -

Other tags:
    See: https://developer.github.com/v3/git/refs/#delete-a-reference -

Returns:
  • (Boolean) - Success

Parameters:
  • branch (String) -- The branch, e.g. fix-refs
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def delete_branch(repo, branch, options = {})
  delete_ref repo, "heads/#{branch}", options
end

def delete_ref(repo, ref, options = {})

Other tags:
    Example: Delete tags/v0.0.3 for sferik/rails_admin -

Other tags:
    See: https://developer.github.com/v3/git/refs/#delete-a-reference -

Returns:
  • (Boolean) - Success

Parameters:
  • ref (String) -- The ref, e.g. tags/v0.0.3
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def delete_ref(repo, ref, options = {})
  boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
end

def matching_refs(repo, ref, options = {})

Other tags:
    Example: Fetch refs matching tags/v2 for sferik/rails_admin -

Other tags:
    See: https://developer.github.com/v3/git/refs/#list-matching-references -

Returns:
  • (Array) - The reference matching the given repo and the ref id

Parameters:
  • ref (String) -- The ref, e.g. tags/v0.0.3 or heads/rails-3
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def matching_refs(repo, ref, options = {})
  paginate "#{Repository.path repo}/git/matching-refs/#{ref}", options
end

def ref(repo, ref, options = {})

Other tags:
    Example: Fetch tags/v0.0.3 for sferik/rails_admin -

Other tags:
    See: https://developer.github.com/v3/git/refs/#get-a-reference -

Returns:
  • (Sawyer::Resource) - The reference matching the given repo and the ref id

Parameters:
  • ref (String) -- The ref, e.g. tags/v0.0.3
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def ref(repo, ref, options = {})
  get "#{Repository.path repo}/git/refs/#{ref}", options
end

def refs(repo, namespace = nil, options = {})

Other tags:
    Example: Fetch all refs for sferik/rails_admin -

Other tags:
    See: https://developer.github.com/v3/git/refs/#get-all-references -

Returns:
  • (Array) - A list of references matching the repo and the namespace

Parameters:
  • namespace (String) -- The ref namespace, e.g. tag or heads
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def refs(repo, namespace = nil, options = {})
  path = "#{Repository.path repo}/git/refs"
  path += "/#{namespace}" unless namespace.nil?
  paginate path, options
end

def update_branch(repo, branch, sha, force = true, options = {})

Other tags:
    Example: Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd -
    Example: Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd -

Other tags:
    See: https://developer.github.com/v3/git/refs/#update-a-reference -

Returns:
  • (Array) - The list of references updated

Parameters:
  • force (Boolean) -- A flag indicating whether to force the update or to make sure the update is a fast-forward update.
  • sha (String) -- A SHA, e.g. 827efc6d56897b048c772eb4087f854f46256132
  • branch (String) -- The ref, e.g. feature/new-shiny
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def update_branch(repo, branch, sha, force = true, options = {})
  update_ref repo, "heads/#{branch}", sha, force, options
end

def update_ref(repo, ref, sha, force = false, options = {})

Other tags:
    Example: Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd -

Other tags:
    See: https://developer.github.com/v3/git/refs/#update-a-reference -

Returns:
  • (Array) - The list of references updated

Parameters:
  • force (Boolean) -- A flag indicating whether to force the update or to make sure the update is a fast-forward update.
  • sha (String) -- A SHA, e.g. 827efc6d56897b048c772eb4087f854f46256132
  • ref (String) -- The ref, e.g. tags/v0.0.3
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def update_ref(repo, ref, sha, force = false, options = {})
  parameters = {
    sha: sha,
    force: force
  }
  patch "#{Repository.path repo}/git/refs/#{ref}", options.merge(parameters)
end