lib/gitlab_git/repository.rb in gitlab_git-10.5.0 vs lib/gitlab_git/repository.rb in gitlab_git-10.6.0
- old
+ new
@@ -25,18 +25,16 @@
attr_reader :name
# Rugged repo object
attr_reader :rugged
- # Define a delegator for the rugged attributes
- def_delegator :rugged, :attributes
-
# 'path' must be the path to a _bare_ git repository, e.g.
# /path/to/my-repo.git
def initialize(path)
@path = path
@name = path.split("/").last
+ @attributes = Attributes.new(path)
end
# Default branch in the repository
def root_ref
@root_ref ||= discover_default_branch
@@ -976,11 +974,17 @@
end
end
# Checks if the blob should be diffable according to its attributes
def diffable?(blob)
- blob_attributes = attributes(blob.path).to_h
- blob_attributes.fetch('diff', blob.text?)
+ attributes(blob.path).fetch('diff') { blob.text? }
+ end
+
+ # Returns the Git attributes for the given file path.
+ #
+ # See `Gitlab::Git::Attributes` for more information.
+ def attributes(path)
+ @attributes.attributes(path)
end
private
# Get the content of a blob for a given commit. If the blob is a commit