Skip to content

Commit

Permalink
Detect GFortran module files as generated
Browse files Browse the repository at this point in the history
  • Loading branch information
pchaigno committed Apr 19, 2015
1 parent da9bda0 commit e073e91
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
13 changes: 9 additions & 4 deletions lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def generated?
generated_protocol_buffer? ||
generated_jni_header? ||
vcr_cassette? ||
generated_kicad_module?
generated_module?
end

# Internal: Is the blob an Xcode file?
Expand Down Expand Up @@ -313,17 +313,22 @@ def compiled_cython_file?
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 changes: 19 additions & 0 deletions test/fixtures/Generated/ms2.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions test/test_blob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@ def test_generated
# 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
Expand Down

0 comments on commit e073e91

Please sign in to comment.