Commit f0f3f385 authored by Robert Schilling's avatar Robert Schilling

Use commit date for branches and tags

parent e80313f9
...@@ -125,11 +125,18 @@ module API ...@@ -125,11 +125,18 @@ module API
delete ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do delete ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
authorize_push_project authorize_push_project
result = DeleteBranchService.new(user_project, current_user) branch = user_project.repository.find_branch(params[:branch])
.execute(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 if result[:status] != :success
render_api_error!(result[:message], result[:return_code]) render_api_error!(result[:message], result[:return_code])
end
end end
end end
......
...@@ -65,11 +65,18 @@ module API ...@@ -65,11 +65,18 @@ module API
delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_push_project authorize_push_project
result = ::Tags::DestroyService.new(user_project, current_user) tag = user_project.repository.find_tag(params[:tag_name])
.execute(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 if result[:status] != :success
render_api_error!(result[:message], result[:return_code]) render_api_error!(result[:message], result[:return_code])
end
end end
end end
......
...@@ -394,7 +394,7 @@ describe API::Tags do ...@@ -394,7 +394,7 @@ describe API::Tags do
it_behaves_like '404 response' do it_behaves_like '404 response' do
let(:request) { put api(route, current_user), description: new_description } let(:request) { put api(route, current_user), description: new_description }
let(:message) { '404 Tag Not Found' } let(:message) { 'Tag does not exist' }
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