Detect source files generated by the Protocol Buffer compiler

This commit is contained in:
Mihai Parparita
2013-04-16 22:14:50 -07:00
parent 9f0964cd7d
commit 6c98bbf02c
7 changed files with 1151 additions and 3 deletions

View File

@@ -56,7 +56,8 @@ module Linguist
compiled_coffeescript? ||
xcode_project_file? ||
generated_net_docfile? ||
generated_parser?
generated_parser? ||
generated_protocol_buffer?
end
# Internal: Is the blob an XCode project file?
@@ -158,5 +159,16 @@ module Linguist
false
end
# Internal: Is the blob a C++, Java or Python source file generated by the
# Protocol Buffer compiler?
#
# Returns true of false.
def generated_protocol_buffer?
return false unless ['.py', '.java', '.h', '.cc', '.cpp'].include?(extname)
return false unless lines.count > 1
return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!")
end
end
end