diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-01-12 02:12:34 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-02-06 18:26:25 +0300 |
commit | d2a77094ae4a44b63fbe22ca910e836cb336a729 (patch) | |
tree | 4c2a33b4ad440355202c8dc9d915957a04a78f44 /app/services/files | |
parent | 321ef1d45b7fad9a73451b97fc55476c77118477 (diff) |
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.
Diffstat (limited to 'app/services/files')
-rw-r--r-- | app/services/files/create_service.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb index 00a8dcf0934..46acdc5406c 100644 --- a/app/services/files/create_service.rb +++ b/app/services/files/create_service.rb @@ -1,10 +1,20 @@ 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, - @file_content, + content_or_lfs_pointer, message: @commit_message, branch_name: @branch_name, author_email: @author_email, |