Module: Gitlab::Client::RepositoryFiles
- Included in:
- Gitlab::Client
- Defined in:
- lib/gitlab/client/repository_files.rb
Overview
Defines methods related to repository files.
Instance Method Summary collapse
-
#create_file(project, path, branch, content, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new repository file.
-
#edit_file(project, path, branch, content, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash
Edits an existing repository file.
-
#file_contents(project, filepath, ref = 'master') ⇒ String
(also: #repo_file_contents)
Get the contents of a file.
-
#get_file(project, file_path, ref) ⇒ Gitlab::ObjectifiedHash
Gets a repository file.
-
#get_file_blame(project, file_path, ref) ⇒ Gitlab::ObjectifiedHash
Get file blame from repository.
-
#remove_file(project, path, branch, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash
Removes an existing repository file.
Instance Method Details
#create_file(project, path, branch, content, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash
Creates a new repository file.
73 74 75 76 77 78 |
# File 'lib/gitlab/client/repository_files.rb', line 73 def create_file(project, path, branch, content, , = {}) post("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { branch: branch, commit_message: }.merge().merge(encoded_content_attributes(content))) end |
#edit_file(project, path, branch, content, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash
Edits an existing repository file.
94 95 96 97 98 99 |
# File 'lib/gitlab/client/repository_files.rb', line 94 def edit_file(project, path, branch, content, , = {}) put("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { branch: branch, commit_message: }.merge().merge(encoded_content_attributes(content))) end |
#file_contents(project, filepath, ref = 'master') ⇒ String Also known as: repo_file_contents
Get the contents of a file
19 20 21 22 23 24 25 |
# File 'lib/gitlab/client/repository_files.rb', line 19 def file_contents(project, filepath, ref = 'master') get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw", query: { ref: ref }, format: nil, headers: { Accept: 'text/plain' }, parser: ::Gitlab::Request::Parser end |
#get_file(project, file_path, ref) ⇒ Gitlab::ObjectifiedHash
Gets a repository file.
53 54 55 56 57 |
# File 'lib/gitlab/client/repository_files.rb', line 53 def get_file(project, file_path, ref) get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}", query: { ref: ref }) end |
#get_file_blame(project, file_path, ref) ⇒ Gitlab::ObjectifiedHash
Get file blame from repository
38 39 40 41 42 |
# File 'lib/gitlab/client/repository_files.rb', line 38 def get_file_blame(project, file_path, ref) get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}/blame", query: { ref: ref }) end |
#remove_file(project, path, branch, commit_message, options = {}) ⇒ Gitlab::ObjectifiedHash
Removes an existing repository file.
114 115 116 117 118 119 120 |
# File 'lib/gitlab/client/repository_files.rb', line 114 def remove_file(project, path, branch, , = {}) delete("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { branch: branch, commit_message: }.merge()) end |