2018-07-16 12:31:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-11-05 05:06:52 -05:00
|
|
|
module Files
|
2015-08-11 08:33:31 -04:00
|
|
|
class CreateService < Files::BaseService
|
2017-04-19 20:37:44 -04:00
|
|
|
def create_commit!
|
2019-06-06 02:51:50 -04:00
|
|
|
transformer = Lfs::FileTransformer.new(project, repository, @branch_name)
|
2018-03-14 19:45:57 -04:00
|
|
|
|
|
|
|
result = transformer.new_file(@file_path, @file_content)
|
|
|
|
|
|
|
|
create_transformed_commit(result.content)
|
2018-01-11 18:12:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_transformed_commit(content_or_lfs_pointer)
|
2017-02-15 18:28:29 -05:00
|
|
|
repository.create_file(
|
2016-11-14 15:02:10 -05:00
|
|
|
current_user,
|
|
|
|
@file_path,
|
2018-01-11 18:12:34 -05:00
|
|
|
content_or_lfs_pointer,
|
2016-12-08 04:08:25 -05:00
|
|
|
message: @commit_message,
|
2017-04-19 20:37:44 -04:00
|
|
|
branch_name: @branch_name,
|
2016-11-14 15:02:10 -05:00
|
|
|
author_email: @author_email,
|
|
|
|
author_name: @author_name,
|
2017-01-06 10:29:13 -05:00
|
|
|
start_project: @start_project,
|
|
|
|
start_branch_name: @start_branch)
|
2015-08-11 08:33:31 -04:00
|
|
|
end
|
2013-11-05 05:06:52 -05:00
|
|
|
end
|
|
|
|
end
|