module Gitlab::Client::RepositoryFiles
def create_file(project, path, branch, content, commit_message, options = {})
-
(Gitlab::ObjectifiedHash)
-
Options Hash:
(**options)
-
:author_email
(String
) -- Commit author's email address -
:author_name
(String
) -- Commit author's name
Parameters:
-
options
(Hash
) -- Optional additional details for commit -
commit_message
(String
) -- ...commit message. -
content
(String
) -- file content. -
branch
(String
) -- the name of the branch. -
path
(String
) -- full path to new file. -
project
(Integer, String
) -- The ID or name of a project.
def create_file(project, path, branch, content, commit_message, options = {}) post("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { branch: branch, commit_message: commit_message }.merge(options).merge(encoded_content_attributes(content))) end
def edit_file(project, path, branch, content, commit_message, options = {})
-
(Gitlab::ObjectifiedHash)
-
Options Hash:
(**options)
-
:author_email
(String
) -- Commit author's email address -
:author_name
(String
) -- Commit author's name
Parameters:
-
options
(Hash
) -- Optional additional details for commit -
commit_message
(String
) -- ...commit message. -
content
(String
) -- new file content. -
branch
(String
) -- the name of the branch to commit changes to. -
path
(String
) -- full path of file to update. -
project
(Integer, String
) -- The ID or name of a project.
def edit_file(project, path, branch, content, commit_message, options = {}) put("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { branch: branch, commit_message: commit_message }.merge(options).merge(encoded_content_attributes(content))) end
def encoded_content_attributes(content)
def encoded_content_attributes(content) { encoding: 'base64', content: Base64.encode64(content) } end
def file_contents(project, filepath, ref = 'master')
-
(String)
-
Parameters:
-
ref
(String
) -- The name of a repository branch or tag or if not given the default branch. -
filepath
(String
) -- The relative path of the file in the repository -
project
(Integer, String
) -- The ID or name of a project.
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
def get_file(project, file_path, ref)
-
(Gitlab::ObjectifiedHash)
-
Parameters:
-
ref
(String
) -- The name of branch, tag or commit. -
file_path
(String
) -- The full path of the file. -
project
(Integer, String
) -- The ID or name of a project.
def get_file(project, file_path, ref) get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}", query: { ref: ref }) end
def get_file_blame(project, file_path, ref)
-
(Gitlab::ObjectifiedHash)
-
Parameters:
-
ref
(String
) -- The name of branch, tag or commit. -
file_path
(String
) -- The full path of the file. -
project
(Integer, String
) -- The ID or name of a project.
def get_file_blame(project, file_path, ref) get("/projects/#{url_encode project}/repository/files/#{url_encode file_path}/blame", query: { ref: ref }) end
def remove_file(project, path, branch, commit_message, options = {})
-
(Gitlab::ObjectifiedHash)
-
Options Hash:
(**options)
-
:author_email
(String
) -- Commit author's email address -
:author_name
(String
) -- Commit author's name
Parameters:
-
options
(Hash
) -- Optional additional details for commit -
commit_message
(String
) -- ...a commit message ;) -
branch
(String
) -- the name of the branch to commit the deletion to. -
path
(String
) -- full path of file to delete. -
project
(Integer, String
) -- The ID or name of a project.
def remove_file(project, path, branch, commit_message, options = {}) delete("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { branch: branch, commit_message: commit_message }.merge(options)) end