-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
project version {major,minor,patch}
CLIs (#633)
See context at #581
- Loading branch information
Showing
3 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::Project; | ||
use miette::{Context, IntoDiagnostic}; | ||
use rattler_conda_types::VersionBumpType; | ||
|
||
pub async fn execute(mut project: Project, bump_type: VersionBumpType) -> miette::Result<()> { | ||
// get version and exit with error if not found | ||
let current_version = project | ||
.version() | ||
.as_ref() | ||
.ok_or_else(|| miette::miette!("No version found in manifest."))? | ||
.clone(); | ||
|
||
// bump version | ||
let new_version = current_version | ||
.bump(bump_type) | ||
.into_diagnostic() | ||
.context("Failed to bump version.")?; | ||
|
||
// Set the version | ||
project.manifest.set_version(&new_version.to_string())?; | ||
|
||
// Save the manifest on disk | ||
project.save()?; | ||
|
||
// Report back to the user | ||
eprintln!( | ||
"{}Updated project version from '{}' to '{}'.", | ||
console::style(console::Emoji("✔ ", "")).green(), | ||
current_version, | ||
new_version, | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters