class Github::GitData::References

def create(user_name, repo_name, params={})


"sha" => "827efc6d56897b048c772eb4087f854f46256132"
"ref" => "refs/heads/master",
github.git_data.references.create 'user-name', 'repo-name',
github = Github.new
= Examples

* :sha - String of the SHA1 value to set this reference to
* :ref - String of the name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.
= Inputs

Create a reference
def create(user_name, repo_name, params={})
  set :user => user_name, :repo => repo_name
  normalize! params
  filter! VALID_REF_PARAM_NAMES, params
  assert_presence_of user, repo, params['ref']
  validate_reference params['ref']
  assert_required_keys(%w[ ref sha ], params)
  post_request("/repos/#{user}/#{repo}/git/refs", params)
end

def delete(user_name, repo_name, ref, params={})


"ref" => "refs/heads/master",
github.git_data.references.delete 'user-name', 'repo-name',
github = Github.new
= Examples

Delete a reference
def delete(user_name, repo_name, ref, params={})
  set :user => user_name, :repo => repo_name
  assert_presence_of user, repo, ref
  normalize! params
  delete_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
end

def get(user_name, repo_name, ref, params={})


github.git_data.references.get 'user-name', 'repo-name', 'heads/branch'
github = Github.new
= Examples

heads/sc/featureA
branch named sc/featureA would be formatted as
not just branch. For example, the call to get the data for a
The ref in the URL must be formatted as heads/branch,

Get a reference
def get(user_name, repo_name, ref, params={})
  set :user => user_name, :repo => repo_name
  assert_presence_of user, repo, ref
  validate_reference ref
  normalize! params
  get_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
end

def initialize(options = {})

Creates new GitData::References API
def initialize(options = {})
  super(options)
end

def list(user_name, repo_name, params={})


github.git_data.references.list 'user-name', 'repo-name', ref:'tags'

github.git_data.references.list 'user-name', 'repo-name'
github = Github.new
= Examples

though that would be the most common.
Anything in the namespace, not just heads and tags,
including things like notes and stashes if they exist on the server.
This will return an array of all the references on the system,

Get all references
def list(user_name, repo_name, params={})
  set :user => user_name, :repo => repo_name
  assert_presence_of user, repo
  normalize! params
  response = if params['ref']
    ref = params.delete('ref')
    validate_reference ref
    get_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
  else
    get_request("/repos/#{user}/#{repo}/git/refs", params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end

def update(user_name, repo_name, ref, params={})


"force" => true
"sha" => "827efc6d56897b048c772eb4087f854f46256132",
github.git_data.references.update 'user-name', 'repo-name', 'heads/master',
github = Github.new
= Examples

* :force - Boolean indicating whether to force the update or to make sure the update is a fast-forward update. The default is false, so leaving this out or setting it to false will make sure you’re not overwriting work.
* :sha - String of the SHA1 value to set this reference to
= Inputs

Update a reference
def update(user_name, repo_name, ref, params={})
  set :user => user_name, :repo => repo_name
  assert_presence_of user, repo, ref
  validate_reference ref
  normalize! params
  filter! VALID_REF_PARAM_NAMES, params
  assert_required_keys(%w[ sha ], params)
  patch_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
end

def validate_reference ref

def validate_reference ref
  refs = ref.index('ref') ? ref : "refs/#{ref}"
  unless VALID_REF_PARAM_VALUES['ref'] =~ refs
    raise ArgumentError, "Provided 'reference' is invalid"
  end
end