-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Running cargo semver-checks with no other arguments should default to checking #459
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.
Love the tests, great idea to use the existing test setup to ensure this functionality works too!
Just a few minor suggestions for further improvement.
src/main.rs
Outdated
let report = check.check_release()?; | ||
if report.success() { | ||
std::process::exit(0) | ||
} else { | ||
std::process::exit(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.
Could we refactor the code here a bit to avoid the duplicated logic?
Maybe something like:
let check: cargo_semver_checks::Check = args.command.unwrap_or_else(|| args.check_release.into());
let report = check.check_release()?;
// ...
tests/feature_config.rs
Outdated
CargoSemverChecks::new_with_check_release_subcommand( | ||
"test_crates/features_simple/new/", | ||
"test_crates/features_simple/old/Cargo.toml", | ||
) | ||
.add_arg("--only-explicit-features") | ||
.run() | ||
.success(); |
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 duplication is a bit unfortunate: over time as we edit these tests and add new ones, we might update one version of the check but fail to update the other. This is a maintainability risk.
Could you think of another way to set up the test where we don't need to duplicate all the test code like this? Perhaps by doing some more refactoring of the CargoSemverChecks
type?
Co-authored-by: Predrag Gruevski <[email protected]>
Let me know if the tests are better now, I thought of adding an Also, not sure about the way I remove the subcommand from args. Let me know if you think it could be better. |
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.
Nicely done! A couple of tiny tweaks and this is good to go 🚀
Thank you again @obi1kenobi for all the reviews! |
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.
Awesome, let's ship it 🚀
Addresses #414.
It allows users to run cargo semver-checks without using the subcommand
check-release
.I basically moved
CheckRelease
to be a field atSemverChecks
.I tried to also remove it from the
SemverChecksCommands::CheckRelease
enum by usingglobal = true
on all fields fromCheckRelease
, but I could not add that property tomanifest
andworkspace
fields.I reused the tests from
feature_config
to make sure the same use cases work when user specifies the subcommand or not.