debian-mirror-gitlab/app/services/files/update_service.rb

28 lines
912 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
module Files
2015-09-25 12:07:36 +05:30
class UpdateService < Files::BaseService
2017-08-17 22:00:37 +05:30
def create_commit!
2016-08-24 12:49:21 +05:30
repository.update_file(current_user, @file_path, @file_content,
2016-09-29 09:46:39 +05:30
message: @commit_message,
2017-08-17 22:00:37 +05:30
branch_name: @branch_name,
previous_path: @previous_path,
2016-09-29 09:46:39 +05:30
author_email: @author_email,
2017-08-17 22:00:37 +05:30
author_name: @author_name,
start_project: @start_project,
2022-06-21 17:19:12 +05:30
start_branch_name: @start_branch,
execute_filemode: @execute_filemode)
2014-09-02 18:07:02 +05:30
end
2016-09-13 17:45:13 +05:30
private
2017-08-17 22:00:37 +05:30
def validate!
super
2018-03-17 18:26:18 +05:30
if file_has_changed?(@file_path, @last_commit_sha)
2019-07-31 22:56:46 +05:30
raise FileChangedError, _('You are attempting to update a file that has changed since you started editing it.')
2017-08-17 22:00:37 +05:30
end
2016-09-13 17:45:13 +05:30
end
2014-09-02 18:07:02 +05:30
end
end