-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add tool to format with pretty-please #2739
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
Edit: Nevermind. I was quick to jump to conclusions. That's our code generator's fault. The new tool failed to run during SDK codegen, and the rustfmt had been removing this redundant semicolon. |
I removed the cargo metadata workspace resolution from the tool since that was what was causing it to fail for the SDK (since it runs before the SDK copies over the runtime crates, and thus, the runtime crates don't exist when resolving the Cargo.toml files with |
A new generated diff is ready to view.
A new doc preview is ready to view. |
Judging from the codegen diff, prettyplease removes all non-doc comments. Not sure if this will work for us. |
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.
Closes #1526.
This would be nice but we need it to preserve comments :(
fileManifest.baseDir, | ||
timeout = settings.codegenConfig.formatTimeoutSeconds.toLong(), | ||
) | ||
} catch (err: CommandFailed) { | ||
logger.info( | ||
"[rust-server-codegen] Failed to run cargo fmt: [${service.id}]\n${err.output}", | ||
"Failed to run please-fmt (be sure to install the tool with " + | ||
"`cargo install --path tools/ci-build/please-fmt`): [${service.id}]\n${err.output}", |
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.
"`cargo install --path tools/ci-build/please-fmt`): [${service.id}]\n${err.output}", | |
"`cargo install --locked --path tools/ci-build/please-fmt`): [${service.id}]\n${err.output}", |
[workspace] | ||
|
||
[dependencies] | ||
argh = "0.1" |
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.
What's the benefit of this over clap
?
Prettyplease doesn't preserve comments and the maintainer doesn't want to support that, so it's not a viable option for smithy-rs. |
Motivation and Context
This PR adds a tool that formats a cargo workspace using the dtolnay/prettyplease library to replace rustfmt since rustfmt fails to format most of our generated code now.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.