mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Detect Cython generated files
This commit is contained in:
@@ -62,6 +62,7 @@ module Linguist
|
|||||||
generated_parser? ||
|
generated_parser? ||
|
||||||
generated_net_docfile? ||
|
generated_net_docfile? ||
|
||||||
generated_postscript? ||
|
generated_postscript? ||
|
||||||
|
compiled_cython_file? ||
|
||||||
generated_protocol_buffer_go? ||
|
generated_protocol_buffer_go? ||
|
||||||
generated_protocol_buffer? ||
|
generated_protocol_buffer? ||
|
||||||
generated_jni_header? ||
|
generated_jni_header? ||
|
||||||
@@ -270,5 +271,17 @@ module Linguist
|
|||||||
# VCR Cassettes have "recorded_with: VCR" in the second last line.
|
# VCR Cassettes have "recorded_with: VCR" in the second last line.
|
||||||
return lines[-2].include?("recorded_with: VCR")
|
return lines[-2].include?("recorded_with: VCR")
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -240,6 +240,10 @@ class TestBlob < Minitest::Test
|
|||||||
# Godep saved dependencies
|
# Godep saved dependencies
|
||||||
assert sample_blob("Godeps/Godeps.json").generated?
|
assert sample_blob("Godeps/Godeps.json").generated?
|
||||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").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
|
end
|
||||||
|
|
||||||
def test_vendored
|
def test_vendored
|
||||||
|
|||||||
Reference in New Issue
Block a user