### Home Classes Methods

### In Files

- lib/github_api/git_data/references.rb

### Parent

API

### Methods

- #all
- #create
- #delete
- #find
- #get
- #list
- #remove
- #update

### Class/Module Index

Quicksearch

- Github
- Github::API
- Github::Activity
- Github::Activity::Events
- Github::Activity::Notifications
- Github::Activity::Starring
- Github::Activity::Watching
- Github::ApiFactory
- Github::Arguments
- Github::Authorization
- Github::Authorizations
- Github::AutoloadHelper
- Github::Client
- Github::Configuration
- Github::Connection
- Github::Constants
- Github::CoreExt
- Github::CoreExt::OrderedHash
- Github::Descendants
- Github::Emojis
- Github::Error
- Github::Error::BadRequest
- Github::Error::ClientError
- Github::Error::Forbidden
- Github::Error::GithubError
- Github::Error::InternalServerError
- Github::Error::InvalidOptions
- Github::Error::NotAcceptable
- Github::Error::NotFound
- Github::Error::RequiredParams
- Github::Error::ServiceError
- Github::Error::ServiceUnavailable
- Github::Error::Unauthorized
- Github::Error::UnknownValue
- Github::Error::UnprocessableEntity
- Github::Error::Validations
- Github::Gists
- Github::Gists::Comments
- Github::GitData
- Github::GitData::Blobs
- Github::GitData::Commits
- Github::GitData::References
- Github::GitData::Tags
- Github::GitData::Trees
- Github::Gitignore
- Github::Issues
- Github::Issues::Assignees
- Github::Issues::Comments
- Github::Issues::Events
- Github::Issues::Labels
- Github::Issues::Milestones
- Github::Jsonable
- Github::Markdown
- Github::Meta
- Github::MimeType
- Github::Normalizer
- Github::Orgs
- Github::Orgs::Members
- Github::Orgs::Teams
- Github::PageIterator
- Github::PageLinks
- Github::PagedRequest
- Github::Pagination
- Github::ParameterFilter
- Github::ParamsHash
- Github::PullRequests
- Github::PullRequests::Comments
- Github::RateLimit
- Github::Repos
- Github::Repos::Collaborators
- Github::Repos::Comments
- Github::Repos::Commits
- Github::Repos::Contents
- Github::Repos::Downloads
- Github::Repos::Forks
- Github::Repos::Hooks
- Github::Repos::Keys
- Github::Repos::Merging
- Github::Repos::PubSubHubbub
- Github::Repos::Statistics
- Github::Repos::Statuses
- Github::Request
- Github::Request::BasicAuth
- Github::Request::Jsonize
- Github::Request::OAuth2
- Github::Resource
- Github::Response
- Github::Response::Header
- Github::Response::Jsonize
- Github::Response::Mashify
- Github::Response::RaiseError
- Github::Response::Xmlize
- Github::ResponseWrapper
- Github::S3Uploader
- Github::Say
- Github::Scopes
- Github::Search
- Github::Users
- Github::Users::Emails
- Github::Users::Followers
- Github::Users::Keys
- Github::Utils
- Github::Utils::Url
- Github::VERSION
- Github::Validations
- Github::Validations::Format
- Github::Validations::Presence
- Github::Validations::Required
- Github::Validations::Token
- Hash

No matching classes.

# Github::GitData::References

### Constants

REQUIRED_REF_PARAMS
VALID_REF_PARAM_NAMES
VALID_REF_PARAM_VALUES

### Public Instance Methods

all(*args) click to toggle source
Alias for: list
create(*args) click to toggle source

Create a reference

# Inputs

- `: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.

- `:sha` - String of the SHA1 value to set this reference to

# Examples

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

    # File lib/github_api/git_data/references.rb, line 73
    def create(*args)
      arguments(args, :required => [:user, :repo]) do
        sift VALID_REF_PARAM_NAMES
        assert_required REQUIRED_REF_PARAMS
      end
      params = arguments.params
      validate_reference params['ref']

      post_request("/repos/#{user}/#{repo}/git/refs", params)
    end

delete(*args) click to toggle source

Delete a reference

# Examples

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

    # File lib/github_api/git_data/references.rb, line 113
    def delete(*args)
      arguments(args, :required => [:user, :repo, :ref])
      params = arguments.params

      delete_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
    end

Also aliased as: remove
find(*args) click to toggle source
Alias for: get
get(*args) click to toggle source

Get a reference

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

# Examples

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

    # File lib/github_api/git_data/references.rb, line 52
    def get(*args)
      arguments(args, :required => [:user, :repo, :ref])
      validate_reference ref
      params = arguments.params

      get_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
    end

Also aliased as: find
list(*args) click to toggle source

Get all references

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

# Examples

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

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

    # File lib/github_api/git_data/references.rb, line 26
    def list(*args)
      arguments(args, :required => [:user, :repo])
      params = arguments.params

      response = if (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

Also aliased as: all
remove(*args) click to toggle source
Alias for: delete
update(*args) click to toggle source

Update a reference

# Inputs

- `:sha` - String of the SHA1 value to set this reference to

- `: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.

# Examples

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

    # File lib/github_api/git_data/references.rb, line 96
    def update(*args)
      arguments(args, :required => [:user, :repo, :ref]) do
        sift VALID_REF_PARAM_NAMES
        assert_required ] sha ]
      end
      params = arguments.params

      patch_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.