Detect GFortran module files as generated

This commit is contained in:
Paul Chaignon
2015-04-19 16:56:38 +02:00
parent da9bda0e27
commit e073e91d62
3 changed files with 28 additions and 7 deletions

View File

@@ -69,7 +69,7 @@ module Linguist
generated_protocol_buffer? ||
generated_jni_header? ||
vcr_cassette? ||
generated_kicad_module?
generated_module?
end
# Internal: Is the blob an Xcode file?
@@ -313,17 +313,22 @@ module Linguist
return lines[0].include?("Generated by Cython")
end
# Internal: Is it a KiCAD module file?
# Internal: Is it a KiCAD or GFortran module file?
#
# KiCAD module files contain:
# PCBNEW-LibModule-V1 yyyy-mm-dd h:mm:ss XM
# on the first line.
#
# GFortran module files contain:
# GFORTRAN module version 'x' created from
# on the first line.
#
# Return true of false
def generated_kicad_module?
def generated_module?
return false unless extname == '.mod'
return false unless lines.count > 1
return lines[0].include?("PCBNEW-LibModule-V")
return lines[0].include?("PCBNEW-LibModule-V") ||
lines[0].include?("GFORTRAN module version '")
end
end
end

19
test/fixtures/Generated/ms2.mod vendored Normal file
View File

@@ -0,0 +1,19 @@
GFORTRAN module version '0' created from ms2.f90 on Thu Sep 5 10:09:19 2013
MD5:8a80cd5db1bc612a28603959302dbf37 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
()
()
()
()
(2 'ms2' 'ms2' 'ms2' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
)
('ms2' 0 2)

View File

@@ -243,9 +243,6 @@ class TestBlob < Minitest::Test
# Cython-generated C/C++
assert sample_blob("C/sgd_fast.c").generated?
assert sample_blob("C++/wrapper_inner.cpp").generated?
# KiCAD module files
assert fixture_blob("Generated/ABM8G.mod").generated?
end
def test_vendored