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 /lib | |
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 'lib')
-rw-r--r-- | lib/carrier_wave_string_file.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/git/lfs_pointer_file.rb | 25 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/carrier_wave_string_file.rb b/lib/carrier_wave_string_file.rb new file mode 100644 index 00000000000..6c848902e4a --- /dev/null +++ b/lib/carrier_wave_string_file.rb @@ -0,0 +1,5 @@ +class CarrierWaveStringFile < StringIO + def original_filename + "" + end +end diff --git a/lib/gitlab/git/lfs_pointer_file.rb b/lib/gitlab/git/lfs_pointer_file.rb new file mode 100644 index 00000000000..da12ed7d125 --- /dev/null +++ b/lib/gitlab/git/lfs_pointer_file.rb @@ -0,0 +1,25 @@ +module Gitlab + module Git + class LfsPointerFile + def initialize(data) + @data = data + end + + def pointer + @pointer ||= <<~FILE + version https://git-lfs.github.com/spec/v1 + oid sha256:#{sha256} + size #{size} + FILE + end + + def size + @size ||= @data.bytesize + end + + def sha256 + @sha256 ||= Digest::SHA256.hexdigest(@data) + end + end + end +end |