mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 12:28:47 +00:00
Adding linguist_vendored? and linguist_generated? to include overrides from .gitattributes
This commit is contained in:
@@ -4,7 +4,7 @@ require 'rugged'
|
||||
|
||||
module Linguist
|
||||
class LazyBlob
|
||||
GIT_ATTR = ['linguist-ignore', 'linguist-lang']
|
||||
GIT_ATTR = ['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)
|
||||
|
||||
@@ -29,12 +29,16 @@ module Linguist
|
||||
name, GIT_ATTR, GIT_ATTR_FLAGS)
|
||||
end
|
||||
|
||||
def ignored?
|
||||
!!git_attributes['linguist-ignore']
|
||||
def linguist_vendored?
|
||||
vendored? || !!git_attributes['linguist-vendored']
|
||||
end
|
||||
|
||||
def linguist_generated?
|
||||
generated? || !!git_attributes['linguist-generated']
|
||||
end
|
||||
|
||||
def overriden_language
|
||||
if lang = git_attributes['linguist-lang']
|
||||
if lang = git_attributes['linguist-language']
|
||||
Language.find_by_name(lang)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,7 +142,7 @@ module Linguist
|
||||
blob = Linguist::LazyBlob.new(repository, delta.new_file[:oid], new, mode.to_s(8))
|
||||
|
||||
# Skip vendored or generated blobs
|
||||
next if blob.ignored? || blob.vendored? || blob.generated? || blob.language.nil?
|
||||
next if blob.linguist_vendored? || blob.linguist_generated? || blob.language.nil?
|
||||
|
||||
# Only include programming languages and acceptable markup languages
|
||||
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
|
||||
|
||||
Reference in New Issue
Block a user