Module: Octokit::Client::Refs
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/refs.rb
Overview
Methods for References for Git Data API
Instance Method Summary collapse
-
#create_ref(repo, ref, sha, options = {}) ⇒ Array<Sawyer::Resource>
(also: #create_reference)
Create a reference.
-
#delete_branch(repo, branch, options = {}) ⇒ Boolean
Delete a single branch.
-
#delete_ref(repo, ref, options = {}) ⇒ Boolean
(also: #delete_reference)
Delete a single reference.
-
#ref(repo, ref, options = {}) ⇒ Sawyer::Resource
(also: #reference)
Fetch a given reference.
-
#refs(repo, namespace = nil, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_refs, #references, #list_references)
List all refs for a given user and repo.
-
#update_branch(repo, branch, sha, force = true, options = {}) ⇒ Array<Sawyer::Resource>
Update a branch.
-
#update_ref(repo, ref, sha, force = true, options = {}) ⇒ Array<Sawyer::Resource>
(also: #update_reference)
Update a reference.
Instance Method Details
#create_ref(repo, ref, sha, options = {}) ⇒ Array<Sawyer::Resource> Also known as: create_reference
Create a reference
48 49 50 51 52 53 54 55 |
# File 'lib/octokit/client/refs.rb', line 48 def create_ref(repo, ref, sha, = {}) ref = "refs/#{ref}" unless ref =~ %r{refs/} parameters = { :ref => ref, :sha => sha } post "#{Repository.path repo}/git/refs", .merge(parameters) end |
#delete_branch(repo, branch, options = {}) ⇒ Boolean
Delete a single branch
99 100 101 |
# File 'lib/octokit/client/refs.rb', line 99 def delete_branch(repo, branch, = {}) delete_ref repo, "heads/#{branch}", end |
#delete_ref(repo, ref, options = {}) ⇒ Boolean Also known as: delete_reference
Delete a single reference
111 112 113 |
# File 'lib/octokit/client/refs.rb', line 111 def delete_ref(repo, ref, = {}) boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", end |
#ref(repo, ref, options = {}) ⇒ Sawyer::Resource Also known as: reference
Fetch a given reference
34 35 36 |
# File 'lib/octokit/client/refs.rb', line 34 def ref(repo, ref, = {}) get "#{Repository.path repo}/git/refs/#{ref}", end |
#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
17 18 19 20 21 |
# File 'lib/octokit/client/refs.rb', line 17 def refs(repo, namespace = nil, = {}) path = "#{Repository.path repo}/git/refs" path += "/#{namespace}" unless namespace.nil? paginate path, end |
#update_branch(repo, branch, sha, force = true, options = {}) ⇒ Array<Sawyer::Resource>
Update a branch
87 88 89 |
# File 'lib/octokit/client/refs.rb', line 87 def update_branch(repo, branch, sha, force = true, = {}) update_ref repo, "heads/#{branch}", sha, force, end |
#update_ref(repo, ref, sha, force = true, options = {}) ⇒ Array<Sawyer::Resource> Also known as: update_reference
Update a reference
68 69 70 71 72 73 74 |
# File 'lib/octokit/client/refs.rb', line 68 def update_ref(repo, ref, sha, force = true, = {}) parameters = { :sha => sha, :force => force } patch "#{Repository.path repo}/git/refs/#{ref}", .merge(parameters) end |