summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2017-03-02 14:21:36 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2017-03-02 16:56:32 +0100
commit7670275b139994d7d95fb9561aae672c7849a8a1 (patch)
tree8dc93b4c5ef3ff2f52832723c815fb9010d9ea50
parent26adf20b42ea06be268551dd710fb5178da37253 (diff)
downloadgitlab-ce-api-delete-respect-headers.tar.gz
Use commit date for branches and tagsapi-delete-respect-headers
-rw-r--r--lib/api/branches.rb15
-rw-r--r--lib/api/tags.rb15
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index 73a7e939627..38c24e6da07 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -121,11 +121,18 @@ module API
delete ":id/repository/branches/:branch", requirements: { branch: /.+/ } do
authorize_push_project
- result = DeleteBranchService.new(user_project, current_user).
- execute(params[:branch])
+ branch = user_project.repository.find_branch(params[:branch])
+ not_found!('Branch') unless branch
+
+ commit = user_project.repository.commit(branch.dereferenced_target)
+
+ destroy_conditionally!(commit, last_update_field: :authored_date) do
+ result = DeleteBranchService.new(user_project, current_user).
+ execute(params[:branch])
- if result[:status] != :success
- render_api_error!(result[:message], result[:return_code])
+ if result[:status] != :success
+ render_api_error!(result[:message], result[:return_code])
+ end
end
end
diff --git a/lib/api/tags.rb b/lib/api/tags.rb
index d31ef9de26b..05ba4df5fc4 100644
--- a/lib/api/tags.rb
+++ b/lib/api/tags.rb
@@ -63,11 +63,18 @@ module API
delete ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do
authorize_push_project
- result = ::Tags::DestroyService.new(user_project, current_user).
- execute(params[:tag_name])
+ tag = user_project.repository.find_tag(params[:tag_name])
+ not_found!('Tag') unless tag
+
+ commit = user_project.repository.commit(tag.dereferenced_target)
+
+ destroy_conditionally!(commit, last_update_field: :authored_date) do
+ result = ::Tags::DestroyService.new(user_project, current_user).
+ execute(params[:tag_name])
- if result[:status] != :success
- render_api_error!(result[:message], result[:return_code])
+ if result[:status] != :success
+ render_api_error!(result[:message], result[:return_code])
+ end
end
end