-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect go files as generated according to official rules #4821
Detect go files as generated according to official rules #4821
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving this!
6a7e41a
to
361bbc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @ernestas2k!
@ernestas2k Can you please add a note to the original post linking to the source of the sample file and the license it is covered by. Thanks. |
The sample file is generated (using the mentioned tool) and located in private repo of mine. Should I find public sample file instead? Like this one https://github.com/deepmap/oapi-codegen/blob/master/examples/petstore-expanded/echo/api/petstore-server.gen.go ? |
@ernestas2k yes please. We need to be able to verify sources in case there are any licensing issues in future. |
@lildude Isn't posting here in a pull request the same as adding it to a public repository under a permissive license? I mean, it's literally what people are doing by posting here. |
@pchaigno sort of. If the file isn't from a source with a verifiable open license, and the author isn't deemed "authoritative" at some point in the future by the owner of the code, it potentially opens GitHub up to legal battles. I know this isn't the case now, but it's best and easier to be consistent across the board. |
@ernestas2k if you're quick, I might just be able to squeeze this into the linguist release I'm currently testing. |
@lildude ok just a moment |
361bbc9
to
9f13b06
Compare
@lildude updated the PR code and the original post, let me know if any more changes would be valuable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ernestas2k 🙇
Use officially accepted rules to detect golang generated files https://golang.org/s/generatedcode
Description
The rule dictates that a line matching
^// Code generated .* DO NOT EDIT\.$
can be anywhere in golang file.I currently use github.com/deepmap/oapi-codegen that generates the following (valid according to the rules) file:
Sample file for test taken from: https://github.com/deepmap/oapi-codegen/blob/master/examples/petstore-expanded/echo/api/petstore-types.gen.go
The project license (apache 2.0) https://github.com/deepmap/oapi-codegen/blob/master/LICENSE
Would be good to get such files ignored automatically by github when reviewing PRs.
This issue was raised and solved multiple times but wasn't merged.
Refs #3800 #2724
Checklist: