diff --git a/lib/linguist/lazy_blob.rb b/lib/linguist/lazy_blob.rb index 78f37b18ee..55c10309c9 100644 --- a/lib/linguist/lazy_blob.rb +++ b/lib/linguist/lazy_blob.rb @@ -4,7 +4,11 @@ module Linguist class LazyBlob - GIT_ATTR = ['linguist-documentation', 'linguist-language', 'linguist-vendored'] + GIT_ATTR = ['linguist-documentation', + 'linguist-language', + 'linguist-vendored', + 'linguist-generated'] + GIT_ATTR_OPTS = { :priority => [:index], :skip_system => true } GIT_ATTR_FLAGS = Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS) @@ -31,22 +35,30 @@ def git_attributes name, GIT_ATTR, GIT_ATTR_FLAGS) end - def vendored? - if attr = git_attributes['linguist-vendored'] - return boolean_attribute(attr) + def documentation? + if attr = git_attributes['linguist-documentation'] + boolean_attribute(attr) else - return super + super end end - def documentation? - if attr = git_attributes['linguist-documentation'] + def generated? + if attr = git_attributes['linguist-generated'] boolean_attribute(attr) else super end end + def vendored? + if attr = git_attributes['linguist-vendored'] + return boolean_attribute(attr) + else + super + end + end + def language return @language if defined?(@language) diff --git a/test/test_repository.rb b/test/test_repository.rb index fcdd4f0c9d..a1f9fc8654 100644 --- a/test/test_repository.rb +++ b/test/test_repository.rb @@ -111,4 +111,14 @@ def test_linguist_override_documentation? refute_predicate readme, :documentation? assert_predicate arduino, :documentation? end + + def test_linguist_override_generated? + attr_commit = "351c1cc8fd57340839bdb400d7812332af80e9bd" + repo = linguist_repo(attr_commit).read_index + + rakefile = Linguist::LazyBlob.new(rugged_repository, attr_commit, "Rakefile") + + # overridden .gitattributes + assert rakefile.generated? + end end