-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add crlf to lf conversion to swagger generation #33613
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
Conversation
I think the last blank line in the v1_json.tmpl is necessary. I tested the |
Are you sure? https://github.com/go-gitea/gitea/pull/33613/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52R277 should ensure that the final newline is added and this behaviour should not have changed with this PR. |
Yes, I manually tested it in my dev machine. |
Confirm this as well, with and without this I have problems on macOS 15 that this line disappears. I will try something as well and report back |
@ChristopherHX thanks, looking forward to your investiation. My issue is that the problem does not reproduce on my machine, so if you can reproduce, that is very helpful. |
I think the reason is that |
After reading code, I believe all these
|
$(SED_INPLACE) -e 's/\r$$//' './$(SWAGGER_SPEC)' # convert crlf to lf | ||
$(SED_INPLACE) -e '$$a\' './$(SWAGGER_SPEC)' # add final newline |
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.
$(SED_INPLACE) -e 's/\r$$//' './$(SWAGGER_SPEC)' # convert crlf to lf | |
$(SED_INPLACE) -e '$$a\' './$(SWAGGER_SPEC)' # add final newline |
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.
I tried this now as well, zero changes on my end
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.
Yes, no final new line is the expected result. Remove the no-sense final new line forever. See #33613 (comment)
just use the output by Go's json.MarshalIndent
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.
This worked at my first try, but no idk what this implies (crlf to lf not needed on my end)
$(SED_INPLACE) -e 's/\r$$//' './$(SWAGGER_SPEC)' # convert crlf to lf | |
$(SED_INPLACE) -e '$$a\' './$(SWAGGER_SPEC)' # add final newline | |
$(SED_INPLACE) -e 's/\r$$//' './$(SWAGGER_SPEC)' # convert crlf to lf | |
echo "" >> './$(SWAGGER_SPEC)' # add final newline |
Now I wonder does this cause issues for others? (At least this is what I understand better as this is simple)
EDIT if we agree of removing final newline enforcement ignore this
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.
This worked at my first try, but no idk what this implies (crlf to lf not needed on my end)
But I do not think the final new line makes sense here. The file content is just a generated JSON output, no one would really edit it.
Ok in this case, if the ci doesn't enforce the final new line I'm for it |
CI will be happy because it works like this:
|
I managed to use another approach to handle the swagger generation. -> Improve swagger generation #33664 |
Replaced by #33664 |
\r
characters from the file, to avoid Windows users from introducing CRLF.-e
argument tosed
, see https://stackoverflow.com/a/66900353/808699 for explanation why both ways with and without-e
work, I think it's better to be explicit about it.