-
Notifications
You must be signed in to change notification settings - Fork 192
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 codegen version to generated package #1621
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
@@ -74,3 +80,6 @@ class CargoTomlGenerator( | |||
writer.writeWithNoFormatting(TomlWriter().write(cargoToml)) | |||
} | |||
} | |||
|
|||
fun smithyCodegenVersion(): String = | |||
try { Version.crateVersion() } catch (ex: Exception) { "unknown" } |
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.
Not needed because it throws in defaultRuntimeCrateVersion
A new generated diff is ready to view.
A new doc preview is ready to view. |
c4235df
to
0198d26
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
fb907fc
to
030cd19
Compare
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. |
val parts = content.split("-") | ||
if (parts.size < 2) { | ||
return "" | ||
} | ||
return parts.first() |
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 you want to go for "the file contains one line", this may not always work; some versions don't follow the format vx.y.z
, like release-2022-08-04
. In this case you should remove the last element, instead of picking the first one
5cd9d69
to
a6646ef
Compare
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. |
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.
Couple comments you may want to address, but nothing blocking from the client side.
Arguments.of( | ||
"0.0.0", | ||
"0.0.0", | ||
"0.0.0", | ||
), | ||
Arguments.of( | ||
"", | ||
"", | ||
"", | ||
), |
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.
Are these valid use-cases? It seems like it should fail in these cases.
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.
Yeah good point, I've updated test cases and the implementation.
@@ -63,6 +64,11 @@ class CargoTomlGenerator( | |||
"edition" to "2021", | |||
"license" to settings.license, | |||
"repository" to settings.moduleRepository, | |||
"metadata" to listOfNotNull( | |||
"smithy" to listOfNotNull( | |||
"codegen-version" to smithyCodegenVersion(), |
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.
Nit: You can call Version.fullVersion()
directly rather than wrapping it in a function.
52cdb15
to
fb56429
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
fb56429
to
2671a36
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
2671a36
to
8b451ca
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
8b451ca
to
a1a7f1f
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
Motivation and Context
Closes #1612
Description
This PR adds smithy-rs's version to generated
Cargo.toml
s. This information later can be fetched viacargo metadata
(or cargo_metadata crate).Testing
It can be tested by generating any package, for example:
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime crates