ebf98f27c4
Enables frozen string for the following: * lib/gitlab/fogbugz_import/**/*.rb * lib/gitlab/gfm/**/*.rb * lib/gitlab/git/**/*.rb * lib/gitlab/gitaly_client/**/*.rb * lib/gitlab/gitlab_import/**/*.rb * lib/gitlab/google_code_import/**/*.rb * lib/gitlab/gpg/**/*.rb * lib/gitlab/grape_logging/**/*.rb * lib/gitlab/graphql/**/*.rb * lib/gitlab/graphs/**/*.rb * lib/gitlab/hashed_storage/**/*.rb * lib/gitlab/health_checks/**/*.rb Partially address gitlab-org/gitlab-ce#47424.
34 lines
669 B
Ruby
34 lines
669 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Git
|
|
class LfsPointerFile
|
|
VERSION = "https://git-lfs.github.com/spec/v1".freeze
|
|
VERSION_LINE = "version #{VERSION}".freeze
|
|
|
|
def initialize(data)
|
|
@data = data
|
|
end
|
|
|
|
def pointer
|
|
@pointer ||= <<~FILE
|
|
#{VERSION_LINE}
|
|
oid sha256:#{sha256}
|
|
size #{size}
|
|
FILE
|
|
end
|
|
|
|
def size
|
|
@size ||= @data.bytesize
|
|
end
|
|
|
|
def sha256
|
|
@sha256 ||= Digest::SHA256.hexdigest(@data)
|
|
end
|
|
|
|
def inspect
|
|
"#<#{self.class}:#{object_id} @size=#{size}, @sha256=#{sha256.inspect}>"
|
|
end
|
|
end
|
|
end
|
|
end
|