Skip to content

Commit

Permalink
Bump line limit for generated_go (#4857)
Browse files Browse the repository at this point in the history
In some cases (e.g. the Cilium project) the `Code generated by` comment
appears after a license header. This header might be longer than 10
lines which generated_go currently searches for this comment.

Bump the limit to 40 lines (roughly corresponding to the length of the
BSD 4-clause header + some slack) to detect these cases.

Suggested by Paul Chaignon in
cilium/cilium#11326 (comment)
  • Loading branch information
tklauser committed May 20, 2020
1 parent 4c29ac5 commit e431970
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def generated_go?
return false unless extname == '.go'
return false unless lines.count > 1

return lines.first(10).any? { |l| l.include? "Code generated by" }
return lines.first(40).any? { |l| l.include? "Code generated by" }
end

PROTOBUF_EXTENSIONS = ['.py', '.java', '.h', '.cc', '.cpp', '.m', '.rb', '.php']
Expand Down

0 comments on commit e431970

Please sign in to comment.