Allow classifier to run on symlinks as usual (#3948)

* Fixups for symlink detection, incl. test

* assert the heuristics return none for symlink
This commit is contained in:
Ashe Connor
2018-01-08 09:01:16 +11:00
committed by GitHub
parent a840668599
commit 5fbe9c0902
5 changed files with 15 additions and 5 deletions

View File

@@ -18,8 +18,6 @@ module Linguist
#
# Returns an Array of Language objects, most probable first.
def self.call(blob, possible_languages)
return [] if blob.symlink?
language_names = possible_languages.map(&:name)
classify(Samples.cache, blob.data[0...CLASSIFIER_CONSIDER_BYTES], language_names).map do |name, _|
Language[name] # Return the actual Language objects

View File

@@ -27,7 +27,7 @@ module Linguist
end
def symlink?
return @symlink if !@symlink.nil?
return @symlink if defined? @symlink
@symlink = (File.symlink?(@fullpath) rescue false)
end