2018-11-09 13:39:43 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-11 18:12:34 -05:00
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class LfsPointerFile
|
2018-03-16 09:35:03 -04:00
|
|
|
VERSION = "https://git-lfs.github.com/spec/v1".freeze
|
|
|
|
VERSION_LINE = "version #{VERSION}".freeze
|
|
|
|
|
2018-01-11 18:12:34 -05:00
|
|
|
def initialize(data)
|
|
|
|
@data = data
|
|
|
|
end
|
|
|
|
|
|
|
|
def pointer
|
|
|
|
@pointer ||= <<~FILE
|
2018-03-16 09:35:03 -04:00
|
|
|
#{VERSION_LINE}
|
2018-01-11 18:12:34 -05:00
|
|
|
oid sha256:#{sha256}
|
|
|
|
size #{size}
|
|
|
|
FILE
|
|
|
|
end
|
|
|
|
|
|
|
|
def size
|
|
|
|
@size ||= @data.bytesize
|
|
|
|
end
|
|
|
|
|
|
|
|
def sha256
|
|
|
|
@sha256 ||= Digest::SHA256.hexdigest(@data)
|
|
|
|
end
|
2018-03-14 19:53:45 -04:00
|
|
|
|
|
|
|
def inspect
|
|
|
|
"#<#{self.class}:#{object_id} @size=#{size}, @sha256=#{sha256.inspect}>"
|
|
|
|
end
|
2018-01-11 18:12:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|