-
Notifications
You must be signed in to change notification settings - Fork 950
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
Set file encoding in GitLab commits #7381
Set file encoding in GitLab commits #7381
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.
Overall changes look good, I made a few suggestions and had one question, lmk your thoughts.
Internally we have a few stability improvements that we need to focus on first before we can accept any contributions, so it'll take a bit of time before we can merge this, just FYI.
@@ -124,6 +125,15 @@ def file_action(file) | |||
end | |||
end | |||
|
|||
# @param [DependencyFile] file | |||
def file_encoding(file) | |||
if file.content_encoding == Dependabot::DependencyFile::ContentEncoding::BASE64 |
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.
if file.content_encoding == Dependabot::DependencyFile::ContentEncoding::BASE64 | |
if file.binary? |
@@ -108,7 +108,8 @@ def file_actions | |||
{ | |||
action: file_action(file), | |||
file_path: file.type == "symlink" ? file.symlink_target : file.path, | |||
content: file.content | |||
content: file.content, | |||
**file_encoding(file) |
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.
Could we pass file.content_encoding
directly? It would be either utf-8
or base64
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 did it like this for two reasons:
- I didn't want to change the behavior for the other case
- I don't want to make any assumption that the string values of constants defined for another purpose match the input required by the GitLab API, even if they happen to do so.
But I'll change it to pass file.content_encoding
directly if you think that is better
0d2b0db
to
04a45f0
Compare
04a45f0
to
6804ba9
Compare
6804ba9
to
0deedaf
Compare
Overlooked that Jurre's suggestions on binary weren't fully implemented... please do that first.
@jeffwidman Not sure I understand what you mean? That code was removed in favor of setting encoding directly to file.content_encoding per the other comment by Jurre #7381 (comment) |
a0173bf
to
e158497
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.
Thanks!
@mikaellanger @jeffwidman GitLab API docs says that encoding should be either text or base64, not utf-8. Text is default. Setting
|
Previously `request_{creator,updater}/gitlab.rb` didn't pass the DependencyFile `content_encoding` to the GitLab API. This caused vendored files (in our case `yarn` `pnp` zip files) to be uploaded as text. --------- Co-authored-by: Mikael Langer <mikael.langer@safeture.com> Co-authored-by: Jeff Widman <jeff@jeffwidman.com>
request_{creator,updater}/gitlab.rb doesn't pass the DependencyFile content_encoding to the GitLab API. This causes vendored files (in our case yarn pnp zip files) to be uploaded as text.