debian-mirror-gitlab/lib/gitlab/git/lfs_pointer_file.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
655 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Gitlab
module Git
class LfsPointerFile
2019-12-04 20:38:33 +05:30
VERSION = "https://git-lfs.github.com/spec/v1"
VERSION_LINE = "version #{VERSION}"
2018-05-09 12:01:36 +05:30
2018-03-17 18:26:18 +05:30
def initialize(data)
@data = data
end
def pointer
@pointer ||= <<~FILE
2018-05-09 12:01:36 +05:30
#{VERSION_LINE}
2018-03-17 18:26:18 +05:30
oid sha256:#{sha256}
size #{size}
FILE
end
def size
@size ||= @data.bytesize
end
def sha256
@sha256 ||= Digest::SHA256.hexdigest(@data)
end
2018-05-09 12:01:36 +05:30
def inspect
"#<#{self.class}:#{object_id} @size=#{size}, @sha256=#{sha256.inspect}>"
end
2018-03-17 18:26:18 +05:30
end
end
end