lib/gitlab_git/repository.rb in gitlab_git-10.0.0 vs lib/gitlab_git/repository.rb in gitlab_git-10.0.1

- old
+ new

@@ -5,10 +5,11 @@ require "rubygems/package" module Gitlab module Git class Repository + extend Forwardable include Gitlab::Git::Popen SEARCH_CONTEXT_LINES = 3 class NoRepository < StandardError; end @@ -22,10 +23,13 @@ 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 @@ -944,9 +948,15 @@ # Create the info directory if needed Dir.mkdir(info_dir_path) unless File.directory?(info_dir_path) # Write the contents of the .gitattributes file to info/attributes File.write(info_attributes_path, gitattributes_content) + 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?) end private # Get the content of a blob for a given commit. If the blob is a commit