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.
-
#matching_refs(repo, ref, options = {}) ⇒ Array<Sawyer::Resource>
Fetch matching refs.
-
#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 = false, 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
60 61 62 63 64 65 66 67 |
# File 'lib/octokit/client/refs.rb', line 60 def create_ref(repo, ref, sha, = {}) ref = "refs/#{ref}" unless ref =~ %r{\Arefs/} parameters = { ref: ref, sha: sha } post "#{Repository.path repo}/git/refs", .merge(parameters) end |
#delete_branch(repo, branch, options = {}) ⇒ Boolean
Delete a single branch
113 114 115 |
# File 'lib/octokit/client/refs.rb', line 113 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
125 126 127 |
# File 'lib/octokit/client/refs.rb', line 125 def delete_ref(repo, ref, = {}) boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", end |
#matching_refs(repo, ref, options = {}) ⇒ Array<Sawyer::Resource>
Fetch matching refs
34 35 36 |
# File 'lib/octokit/client/refs.rb', line 34 def matching_refs(repo, ref, = {}) paginate "#{Repository.path repo}/git/matching-refs/#{ref}", end |
#ref(repo, ref, options = {}) ⇒ Sawyer::Resource Also known as: reference
Fetch a given reference
46 47 48 |
# File 'lib/octokit/client/refs.rb', line 46 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
101 102 103 |
# File 'lib/octokit/client/refs.rb', line 101 def update_branch(repo, branch, sha, force = true, = {}) update_ref repo, "heads/#{branch}", sha, force, end |
#update_ref(repo, ref, sha, force = false, options = {}) ⇒ Array<Sawyer::Resource> Also known as: update_reference
Update a reference
80 81 82 83 84 85 86 |
# File 'lib/octokit/client/refs.rb', line 80 def update_ref(repo, ref, sha, force = false, = {}) parameters = { sha: sha, force: force } patch "#{Repository.path repo}/git/refs/#{ref}", .merge(parameters) end |