Override languages being included by language statistics (#3807)

* Add detectable key to languages

This key allows to override the language being included in the
language stats of a repository.

* Make detectable override-able using .gitattributes

* Mention `linguist-detectable` in README

* Remove detectable key from languages

Reverts changes in 0f7c0df5.

* Update commit hash to the one that was merged

PR #3806 changed the commit hash. The original commit was not
actually merged into the test/attributes branch.

* Fix check to ensure detectable is defined

* Add include in language stats tests when detectable set

* Ignore detectable when vendored, documentation or overridden

* Add documentation on detectable override in README

* Improve documentation on detectable override in README
This commit is contained in:
Seppe Stas
2018-01-23 13:17:48 +01:00
committed by Colin Seymour
parent fef7a12c85
commit 8da6ddf9d9
5 changed files with 71 additions and 3 deletions

View File

@@ -383,7 +383,10 @@ module Linguist
!vendored? &&
!documentation? &&
!generated? &&
language && DETECTABLE_TYPES.include?(language.type)
language && ( defined?(detectable?) && !detectable?.nil? ?
detectable? :
DETECTABLE_TYPES.include?(language.type)
)
end
end
end

View File

@@ -7,7 +7,8 @@ module Linguist
GIT_ATTR = ['linguist-documentation',
'linguist-language',
'linguist-vendored',
'linguist-generated']
'linguist-generated',
'linguist-detectable']
GIT_ATTR_OPTS = { :priority => [:index], :skip_system => true }
GIT_ATTR_FLAGS = Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS)
@@ -70,6 +71,14 @@ module Linguist
end
end
def detectable?
if attr = git_attributes['linguist-detectable']
return boolean_attribute(attr)
else
nil
end
end
def data
load_blob!
@data