Detect Cython generated files

This commit is contained in:
Paul Chaignon
2015-03-14 19:43:17 +01:00
parent f36d239b85
commit 0db133ffb2
2 changed files with 17 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ module Linguist
generated_parser? ||
generated_net_docfile? ||
generated_postscript? ||
compiled_cython_file? ||
generated_protocol_buffer_go? ||
generated_protocol_buffer? ||
generated_jni_header? ||
@@ -270,5 +271,17 @@ module Linguist
# VCR Cassettes have "recorded_with: VCR" in the second last line.
return lines[-2].include?("recorded_with: VCR")
end
# Internal: Is this a compiled C/C++ file from Cython?
#
# Cython-compiled C/C++ files typically contain:
# /* Generated by Cython x.x.x on ... */
# on the first line.
#
# Return true or false
def compiled_cython_file?
return false unless ['.c', '.cpp'].include? extname
return lines[0].include?("Generated by Cython")
end
end
end

View File

@@ -240,6 +240,10 @@ class TestBlob < Minitest::Test
# Godep saved dependencies
assert sample_blob("Godeps/Godeps.json").generated?
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
# Cython-generated C/C++
assert sample_blob("C/sgd_fast.c").generated?
assert sample_blob("C++/wrapper_inner.cpp").generated?
end
def test_vendored