gitlab-org--gitlab-foss/app/services/files/create_service.rb
James Edwards-Jones d2a77094ae File upload UI obeys LFS filters
Uses Lfs::FileModificationHandler to coordinate LFS detection, creation of LfsObject, etc

Caveats:
 1. This isn't used by the multi-file editor / Web IDE
 2. This isn't used on rename. We'd need to be able to download LFS files
    and add them to the commit if they no longer match so not as simple.
 3. We only check the root .gitattributes file, so this should be improved
    to correctly check for nested .gitattributes files in subfolders.
2018-02-06 15:26:25 +00:00

26 lines
722 B
Ruby

module Files
class CreateService < Files::BaseService
def create_commit!
handler = Lfs::FileModificationHandler.new(project, @branch_name)
handler.new_file(@file_path, @file_content) do |content_or_lfs_pointer|
create_transformed_commit(content_or_lfs_pointer)
end
end
private
def create_transformed_commit(content_or_lfs_pointer)
repository.create_file(
current_user,
@file_path,
content_or_lfs_pointer,
message: @commit_message,
branch_name: @branch_name,
author_email: @author_email,
author_name: @author_name,
start_project: @start_project,
start_branch_name: @start_branch)
end
end
end