mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge pull request #2619 from github/linguist-generated
Adding support for generated overrides
This commit is contained in:
@@ -4,7 +4,11 @@ require 'rugged'
|
|||||||
|
|
||||||
module Linguist
|
module Linguist
|
||||||
class LazyBlob
|
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_OPTS = { :priority => [:index], :skip_system => true }
|
||||||
GIT_ATTR_FLAGS = Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS)
|
GIT_ATTR_FLAGS = Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS)
|
||||||
|
|
||||||
@@ -31,14 +35,6 @@ module Linguist
|
|||||||
name, GIT_ATTR, GIT_ATTR_FLAGS)
|
name, GIT_ATTR, GIT_ATTR_FLAGS)
|
||||||
end
|
end
|
||||||
|
|
||||||
def vendored?
|
|
||||||
if attr = git_attributes['linguist-vendored']
|
|
||||||
return boolean_attribute(attr)
|
|
||||||
else
|
|
||||||
return super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def documentation?
|
def documentation?
|
||||||
if attr = git_attributes['linguist-documentation']
|
if attr = git_attributes['linguist-documentation']
|
||||||
boolean_attribute(attr)
|
boolean_attribute(attr)
|
||||||
@@ -47,6 +43,22 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
def language
|
||||||
return @language if defined?(@language)
|
return @language if defined?(@language)
|
||||||
|
|
||||||
|
|||||||
@@ -111,4 +111,14 @@ class TestRepository < Minitest::Test
|
|||||||
refute_predicate readme, :documentation?
|
refute_predicate readme, :documentation?
|
||||||
assert_predicate arduino, :documentation?
|
assert_predicate arduino, :documentation?
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user