diff options
Diffstat (limited to 'lib/api/files.rb')
-rw-r--r-- | lib/api/files.rb | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb index ca59d330e1c..c40fd29490e 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -22,7 +22,7 @@ module API file_content_encoding: attrs[:encoding], author_email: attrs[:author_email], author_name: attrs[:author_name], - last_commit_sha: attrs[:last_commit_id] + last_commit_sha: attrs[:last_commit_id], } end @@ -30,19 +30,19 @@ module API authorize! :download_code, user_project @commit = user_project.commit(params[:ref]) - not_found!('Commit') unless @commit + not_found!("Commit") unless @commit @repo = user_project.repository @blob = @repo.blob_at(@commit.sha, params[:file_path]) - not_found!('File') unless @blob + not_found!("File") unless @blob @blob.load_all_data! end def commit_response(attrs) { file_path: attrs[:file_path], - branch: attrs[:branch] + branch: attrs[:branch], } end @@ -56,37 +56,37 @@ module API ref: params[:ref], blob_id: @blob.id, commit_id: @commit.id, - last_commit_id: @repo.last_commit_id_for_path(@commit.sha, params[:file_path]) + last_commit_id: @repo.last_commit_id_for_path(@commit.sha, params[:file_path]), } end params :simple_file_params do - requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' - requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.', allow_blank: false - requires :commit_message, type: String, allow_blank: false, desc: 'Commit message' - optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from' - optional :author_email, type: String, desc: 'The email of the author' - optional :author_name, type: String, desc: 'The name of the author' + requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb" + requires :branch, type: String, desc: "Name of the branch to commit into. To create a new branch, also provide `start_branch`.", allow_blank: false + requires :commit_message, type: String, allow_blank: false, desc: "Commit message" + optional :start_branch, type: String, desc: "Name of the branch to start the new commit from" + optional :author_email, type: String, desc: "The email of the author" + optional :author_name, type: String, desc: "The name of the author" end params :extended_file_params do use :simple_file_params - requires :content, type: String, desc: 'File content' - optional :encoding, type: String, values: %w[base64], desc: 'File encoding' - optional :last_commit_id, type: String, desc: 'Last known commit id for this file' + requires :content, type: String, desc: "File content" + optional :encoding, type: String, values: %w[base64], desc: "File encoding" + optional :last_commit_id, type: String, desc: "Last known commit id for this file" end end params do - requires :id, type: String, desc: 'The project ID' + requires :id, type: String, desc: "The project ID" end resource :projects, requirements: FILE_ENDPOINT_REQUIREMENTS do - allow_access_with_scope :read_repository, if: -> (request) { request.get? || request.head? } + allow_access_with_scope :read_repository, if: ->(request) { request.get? || request.head? } - desc 'Get raw file metadata from repository' + desc "Get raw file metadata from repository" params do - requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' - requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false + requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb" + requires :ref, type: String, desc: "The name of branch, tag or commit", allow_blank: false end head ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! @@ -94,10 +94,10 @@ module API set_http_headers(blob_data) end - desc 'Get raw file contents from the repository' + desc "Get raw file contents from the repository" params do - requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' - requires :ref, type: String, desc: 'The name of branch, tag commit', allow_blank: false + requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb" + requires :ref, type: String, desc: "The name of branch, tag commit", allow_blank: false end get ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! @@ -107,10 +107,10 @@ module API send_git_blob @repo, @blob end - desc 'Get file metadata from repository' + desc "Get file metadata from repository" params do - requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' - requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false + requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb" + requires :ref, type: String, desc: "The name of branch, tag or commit", allow_blank: false end head ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! @@ -118,10 +118,10 @@ module API set_http_headers(blob_data) end - desc 'Get a file from the repository' + desc "Get a file from the repository" params do - requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' - requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false + requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb" + requires :ref, type: String, desc: "The name of branch, tag or commit", allow_blank: false end get ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do assign_file_vars! @@ -133,7 +133,7 @@ module API data.merge(content: Base64.strict_encode64(@blob.data)) end - desc 'Create new file in repository' + desc "Create new file in repository" params do use :extended_file_params end @@ -151,7 +151,7 @@ module API end end - desc 'Update existing file in repository' + desc "Update existing file in repository" params do use :extended_file_params end @@ -175,7 +175,7 @@ module API end end - desc 'Delete an existing file in repository' + desc "Delete an existing file in repository" params do use :simple_file_params end |