Commit 32d7332d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

API: delete file from repository

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent bd20ec1a
...@@ -397,3 +397,15 @@ Parameters: ...@@ -397,3 +397,15 @@ Parameters:
+ `branch_name` (required) - The name of branch + `branch_name` (required) - The name of branch
+ `content` (required) - New file content + `content` (required) - New file content
+ `commit_message` (required) - Commit message + `commit_message` (required) - Commit message
## Delete existing file in repository
```
DELETE /projects/:id/repository/files
```
Parameters:
+ `file_path` (required) - Full path to file. Ex. lib/class.rb
+ `branch_name` (required) - The name of branch
+ `commit_message` (required) - Commit message
...@@ -40,8 +40,7 @@ module API ...@@ -40,8 +40,7 @@ module API
# Update existing file in repository # Update existing file in repository
# #
# Parameters: # Parameters:
# file_name (required) - The name of new file. Ex. class.rb # file_path (optional) - The path to file. Ex. lib/class.rb
# file_path (optional) - The path to new file. Ex. lib/
# branch_name (required) - The name of branch # branch_name (required) - The name of branch
# content (required) - File content # content (required) - File content
# commit_message (required) - Commit message # commit_message (required) - Commit message
...@@ -67,7 +66,36 @@ module API ...@@ -67,7 +66,36 @@ module API
render_api_error!(result[:error], 400) render_api_error!(result[:error], 400)
end end
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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment