123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::Refs

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/client/refs.rb

Overview

Methods for References for Git Data API

Instance Method Summary

Instance Method Details

#create_ref(repo, ref, sha, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #create_reference

Create a reference

Examples:

Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132

Octokit.create_ref("octocat/Hello-World", "heads/master", "827efc6d56897b048c772eb4087f854f46256132")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • ref (String)

    The ref, e.g. tags/v0.0.3

  • sha (String)

    A SHA, e.g. 827efc6d56897b048c772eb4087f854f46256132

Returns:

  • (Array<Sawyer::Resource>)

    The list of references, already containing the new one

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 60

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

#create_reference(repo, ref, sha, options = {})

Alias for #create_ref.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 68

alias create_reference create_ref

#delete_branch(repo, branch, options = {}) ⇒ Boolean

Delete a single branch

Examples:

Delete uritemplate for sigmavirus24/github3.py

Octokit.delete_branch("sigmavirus24/github3.py", "uritemplate")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • branch (String)

    The branch, e.g. fix-refs

Returns:

  • (Boolean)

    Success

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 113

def delete_branch(repo, branch, options = {})
  delete_ref repo, "heads/#{branch}", options
end

#delete_ref(repo, ref, options = {}) ⇒ Boolean Also known as: #delete_reference

Delete a single reference

Examples:

Delete tags/v0.0.3 for sferik/rails_admin

Octokit.delete_ref("sferik/rails_admin","tags/v0.0.3")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • ref (String)

    The ref, e.g. tags/v0.0.3

Returns:

  • (Boolean)

    Success

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 125

def delete_ref(repo, ref, options = {})
  boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
end

#delete_reference(repo, ref, options = {})

Alias for #delete_ref.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 128

alias delete_reference delete_ref

#list_references(repo, namespace = nil, options = {})

Alias for #refs.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 24

alias list_references refs

#list_refs(repo, namespace = nil, options = {})

Alias for #refs.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 22

alias list_refs refs

#matching_refs(repo, ref, options = {}) ⇒ Array<Sawyer::Resource>

Fetch matching refs

Examples:

Fetch refs matching tags/v2 for sferik/rails_admin

Octokit.ref("sferik/rails_admin","tags/v2")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • ref (String)

    The ref, e.g. tags/v0.0.3 or heads/rails-3

Returns:

  • (Array<Sawyer::Resource>)

    The reference matching the given repo and the ref id

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 34

def matching_refs(repo, ref, options = {})
  paginate "#{Repository.path repo}/git/matching-refs/#{ref}", options
end

#ref(repo, ref, options = {}) ⇒ Sawyer::Resource Also known as: #reference

Fetch a given reference

Examples:

Fetch tags/v0.0.3 for sferik/rails_admin

Octokit.ref("sferik/rails_admin","tags/v0.0.3")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • ref (String)

    The ref, e.g. tags/v0.0.3

Returns:

  • (Sawyer::Resource)

    The reference matching the given repo and the ref id

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 46

def ref(repo, ref, options = {})
  get "#{Repository.path repo}/git/refs/#{ref}", options
end

#reference(repo, ref, options = {})

Alias for #ref.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 49

alias reference ref

#references(repo, namespace = nil, options = {})

Alias for #refs.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 23

alias references refs

#refs(repo, namespace = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #list_refs, #references, #list_references

List all refs for a given user and repo

Examples:

Fetch all refs for sferik/rails_admin

Octokit.refs("sferik/rails_admin")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • namespace (String) (defaults to: nil)

    The ref namespace, e.g. tag or heads

Returns:

  • (Array<Sawyer::Resource>)

    A list of references matching the repo and the namespace

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 17

def refs(repo, namespace = nil, options = {})
  path = "#{Repository.path repo}/git/refs"
  path += "/#{namespace}" unless namespace.nil?
  paginate path, options
end

#update_branch(repo, branch, sha, force = true, options = {}) ⇒ Array<Sawyer::Resource>

Update a branch

Examples:

Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd

Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")

Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd

Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • branch (String)

    The ref, e.g. feature/new-shiny

  • sha (String)

    A SHA, e.g. 827efc6d56897b048c772eb4087f854f46256132

  • force (Boolean) (defaults to: true)

    A flag indicating whether to force the update or to make sure the update is a fast-forward update.

Returns:

  • (Array<Sawyer::Resource>)

    The list of references updated

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 101

def update_branch(repo, branch, sha, force = true, options = {})
  update_ref repo, "heads/#{branch}", sha, force, options
end

#update_ref(repo, ref, sha, force = false, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #update_reference

Update a reference

Examples:

Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd

Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • ref (String)

    The ref, e.g. tags/v0.0.3

  • sha (String)

    A SHA, e.g. 827efc6d56897b048c772eb4087f854f46256132

  • force (Boolean) (defaults to: false)

    A flag indicating whether to force the update or to make sure the update is a fast-forward update.

Returns:

  • (Array<Sawyer::Resource>)

    The list of references updated

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 80

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

#update_reference(repo, ref, sha, force = false, options = {})

Alias for #update_ref.

[ GitHub ]

  
# File 'lib/octokit/client/refs.rb', line 87

alias update_reference update_ref