diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-19 16:33:38 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-11-19 16:33:38 +0200 |
commit | 32d7332d2c9fe21db74073e65d1317c11dc2c861 (patch) | |
tree | c3e8ab67364b3b462490c7c947c1696f53c0790f /lib/api/files.rb | |
parent | bd20ec1a3415a9f945b5052a8f0f83cbd2806837 (diff) | |
download | gitlab-ce-32d7332d2c9fe21db74073e65d1317c11dc2c861.tar.gz |
API: delete file from repository
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/api/files.rb')
-rw-r--r-- | lib/api/files.rb | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb index e467b0f8e9a..588c27d5692 100644 --- a/lib/api/files.rb +++ b/lib/api/files.rb @@ -40,8 +40,7 @@ module API # Update existing file in repository # # Parameters: - # file_name (required) - The name of new file. Ex. class.rb - # file_path (optional) - The path to new file. Ex. lib/ + # file_path (optional) - The path to file. Ex. lib/class.rb # branch_name (required) - The name of branch # content (required) - File content # commit_message (required) - Commit message @@ -67,7 +66,36 @@ module API render_api_error!(result[:error], 400) end end + + # Delete existing file in repository + # + # Parameters: + # file_path (optional) - The path to file. Ex. lib/class.rb + # branch_name (required) - The name of branch + # content (required) - File content + # commit_message (required) - Commit message + # + # Example Request: + # DELETE /projects/:id/repository/files + # + delete ":id/repository/files" do + required_attributes! [:file_path, :branch_name, :commit_message] + attrs = attributes_for_keys [:file_path, :branch_name, :commit_message] + branch_name = attrs.delete(:branch_name) + file_path = attrs.delete(:file_path) + result = ::Files::DeleteContext.new(user_project, current_user, attrs, branch_name, file_path).execute + + if result[:status] == :success + status(200) + + { + file_path: file_path, + branch_name: branch_name + } + else + render_api_error!(result[:error], 400) + end + end end end end - |