2014-09-02 18:07:02 +05:30
|
|
|
module Files
|
2017-08-17 22:00:37 +05:30
|
|
|
class BaseService < Commits::CreateService
|
2018-03-17 18:26:18 +05:30
|
|
|
FileChangedError = Class.new(StandardError)
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def initialize(*args)
|
|
|
|
super
|
2016-01-14 18:37:52 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
@author_email = params[:author_email]
|
|
|
|
@author_name = params[:author_name]
|
2015-09-25 12:07:36 +05:30
|
|
|
@commit_message = params[:commit_message]
|
2018-03-17 18:26:18 +05:30
|
|
|
@last_commit_sha = params[:last_commit_sha]
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
@file_path = params[:file_path]
|
|
|
|
@previous_path = params[:previous_path]
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
@file_content = params[:file_content]
|
|
|
|
@file_content = Base64.decode64(@file_content) if params[:file_content_encoding] == 'base64'
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def file_has_changed?(path, commit_id)
|
|
|
|
return false unless commit_id
|
|
|
|
|
|
|
|
last_commit = Gitlab::Git::Commit
|
|
|
|
.last_for_path(@start_project.repository, @start_branch, path)
|
|
|
|
|
|
|
|
return false unless last_commit
|
|
|
|
|
|
|
|
last_commit.sha != commit_id
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|