2018-07-16 16:31:01 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-11-19 14:14:06 +00:00
|
|
|
module Files
|
2017-04-20 00:37:44 +00:00
|
|
|
class DeleteService < Files::BaseService
|
|
|
|
def create_commit!
|
2017-02-15 23:28:29 +00:00
|
|
|
repository.delete_file(
|
2016-11-14 20:02:10 +00:00
|
|
|
current_user,
|
|
|
|
@file_path,
|
2016-12-08 09:08:25 +00:00
|
|
|
message: @commit_message,
|
2017-04-20 00:37:44 +00:00
|
|
|
branch_name: @branch_name,
|
2016-11-14 20:02:10 +00:00
|
|
|
author_email: @author_email,
|
|
|
|
author_name: @author_name,
|
2017-01-06 15:29:13 +00:00
|
|
|
start_project: @start_project,
|
|
|
|
start_branch_name: @start_branch)
|
2013-11-19 14:14:06 +00:00
|
|
|
end
|
2017-12-20 15:57:27 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def validate!
|
|
|
|
super
|
|
|
|
|
|
|
|
if file_has_changed?(@file_path, @last_commit_sha)
|
2019-04-15 12:25:48 +00:00
|
|
|
raise FileChangedError, _("You are attempting to delete a file that has been previously updated.")
|
2017-12-20 15:57:27 +00:00
|
|
|
end
|
|
|
|
end
|
2013-11-19 14:14:06 +00:00
|
|
|
end
|
|
|
|
end
|