Module: Gitlab::Client::Repositories
- Included in:
- Gitlab::Client
- Defined in:
- lib/gitlab/client/repositories.rb
Overview
Defines methods related to repositories.
Instance Method Summary collapse
-
#compare(project, from, to) ⇒ Gitlab::ObjectifiedHash
(also: #repo_compare)
Compares branches, tags or commits.
-
#file_contents(project, filepath, ref = 'master') ⇒ String
(also: #repo_file_contents)
Get the contents of a file.
-
#repo_archive(project, ref = 'master') ⇒ Gitlab::FileResponse
Get project repository archive.
-
#tree(project, options = {}) ⇒ Gitlab::ObjectifiedHash
(also: #repo_tree)
Get file tree project (root level).
Instance Method Details
#compare(project, from, to) ⇒ Gitlab::ObjectifiedHash Also known as: repo_compare
Compares branches, tags or commits.
73 74 75 |
# File 'lib/gitlab/client/repositories.rb', line 73 def compare(project, from, to) get("/projects/#{project}/repository/compare", query: { from: from, to: to }) end |
#file_contents(project, filepath, ref = 'master') ⇒ String Also known as: repo_file_contents
Get the contents of a file
15 16 17 18 19 20 21 |
# File 'lib/gitlab/client/repositories.rb', line 15 def file_contents(project, filepath, ref='master') ref = URI.encode(ref, /\W/) get "/projects/#{project}/repository/blobs/#{ref}?filepath=#{filepath}", format: nil, headers: { Accept: 'text/plain' }, parser: ::Gitlab::Request::Parser end |
#repo_archive(project, ref = 'master') ⇒ Gitlab::FileResponse
Get project repository archive
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gitlab/client/repositories.rb', line 49 def repo_archive(project, ref = 'master') get("/projects/#{project}/repository/archive", format: nil, headers: { Accept: 'application/octet-stream' }, query: { sha: ref }, parser: proc { |body, _| if body.encoding == Encoding::ASCII_8BIT # binary response ::Gitlab::FileResponse.new StringIO.new(body, 'rb+') else # error with json response ::Gitlab::Request.parse(body) end }) end |
#tree(project, options = {}) ⇒ Gitlab::ObjectifiedHash Also known as: repo_tree
Get file tree project (root level).
35 36 37 |
# File 'lib/gitlab/client/repositories.rb', line 35 def tree(project, ={}) get("/projects/#{project}/repository/tree", query: ) end |