Module: Octokit::Client::Refs

Included in:
Octokit::Client
Defined in:
lib/octokit/client/refs.rb

Instance Method Summary collapse

Instance Method Details

#create_ref(repo, ref, sha, options = {}) ⇒ Array 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 (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)

    The list of references, already containing the new one

See Also:



42
43
44
45
46
47
48
# File 'lib/octokit/client/refs.rb', line 42

def create_ref(repo, ref, sha, options={})
  parameters = {
    :ref  => "refs/#{ref}",
    :sha  => sha
  }
  post("repos/#{Repository.new(repo)}/git/refs", options.merge(parameters))
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 (String, Repository, Hash)

    A GitHub repository

  • ref (String)

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

Returns:

  • (Boolean)

    Success

See Also:



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

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

#ref(repo, ref, options = {}) ⇒ Reference 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 (String, Repository, Hash)

    A GitHub repository

  • ref (String)

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

Returns:

  • (Reference)

    The reference matching the given repo and the ref id

See Also:



28
29
30
# File 'lib/octokit/client/refs.rb', line 28

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

#refs(repo, namespace = "", options = {}) ⇒ Array 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 (String, Repository, Hash)

    A GitHub repository

  • namespace (String) (defaults to: "")

    The ref namespace, e.g. tag or heads

Returns:

  • (Array)

    A list of references matching the repo and the namespace

See Also:



13
14
15
# File 'lib/octokit/client/refs.rb', line 13

def refs(repo, namespace="", options={})
  get("repos/#{Repository.new(repo)}/git/refs/#{namespace}", options)
end

#update_ref(repo, ref, sha, force = true, options = {}) ⇒ Array 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 (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: true)

    A flag indicating one wants to force the update to make sure the update is a fast-forward update.

Returns:

  • (Array)

    The list of references updated

See Also:



61
62
63
64
65
66
67
# File 'lib/octokit/client/refs.rb', line 61

def update_ref(repo, ref, sha, force=true, options={})
  parameters = {
    :sha  => sha,
    :force => force
  }
  patch("repos/#{Repository.new(repo)}/git/refs/#{ref}", options.merge(parameters))
end