diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-11-15 21:12:30 +0100 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-11-19 17:59:33 +0100 |
| commit | 93d5ccdba7ce49525a43fd0c05b707aedbf8aa12 (patch) | |
| tree | 5dbcf6adec867f4d0e317e84e049ca9f41390c5b /clippy_dev/src | |
| parent | 66715532ab313f506f77897567b5ad823f7c4266 (diff) | |
| download | rust-93d5ccdba7ce49525a43fd0c05b707aedbf8aa12.tar.gz rust-93d5ccdba7ce49525a43fd0c05b707aedbf8aa12.zip | |
Add `cargo dev release` subcommand
Currently this only provides the feature to auto-update the versions in the `Cargo.toml` files. With the move to Josh, a command to get beta and stable release commits will be added.
Diffstat (limited to 'clippy_dev/src')
| -rw-r--r-- | clippy_dev/src/lib.rs | 1 | ||||
| -rw-r--r-- | clippy_dev/src/main.rs | 20 | ||||
| -rw-r--r-- | clippy_dev/src/release.rs | 27 |
3 files changed, 47 insertions, 1 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 6505b33d345..9280369c23b 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -18,6 +18,7 @@ pub mod dogfood; pub mod fmt; pub mod lint; pub mod new_lint; +pub mod release; pub mod serve; pub mod setup; pub mod sync; diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 541ce50b6e0..56ed60256f1 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -3,7 +3,7 @@ #![warn(rust_2018_idioms, unused_lifetimes)] use clap::{Args, Parser, Subcommand}; -use clippy_dev::{dogfood, fmt, lint, new_lint, serve, setup, sync, update_lints, utils}; +use clippy_dev::{dogfood, fmt, lint, new_lint, release, serve, setup, sync, update_lints, utils}; use std::convert::Infallible; fn main() { @@ -78,6 +78,9 @@ fn main() { DevCommand::Sync(SyncCommand { subcommand }) => match subcommand { SyncSubcommand::UpdateNightly => sync::update_nightly(), }, + DevCommand::Release(ReleaseCommand { subcommand }) => match subcommand { + ReleaseSubcommand::BumpVersion => release::bump_version(), + }, } } @@ -230,6 +233,8 @@ enum DevCommand { }, /// Sync between the rust repo and the Clippy repo Sync(SyncCommand), + /// Manage Clippy releases + Release(ReleaseCommand), } #[derive(Args)] @@ -309,3 +314,16 @@ enum SyncSubcommand { /// Update nightly version in rust-toolchain and `clippy_utils` UpdateNightly, } + +#[derive(Args)] +struct ReleaseCommand { + #[command(subcommand)] + subcommand: ReleaseSubcommand, +} + +#[derive(Subcommand)] +enum ReleaseSubcommand { + #[command(name = "bump_version")] + /// Bump the version in the Cargo.toml files + BumpVersion, +} diff --git a/clippy_dev/src/release.rs b/clippy_dev/src/release.rs new file mode 100644 index 00000000000..ac755168701 --- /dev/null +++ b/clippy_dev/src/release.rs @@ -0,0 +1,27 @@ +use std::fmt::Write; +use std::path::Path; + +use crate::utils::{UpdateMode, clippy_version, replace_region_in_file}; + +const CARGO_TOML_FILES: [&str; 4] = [ + "clippy_config/Cargo.toml", + "clippy_lints/Cargo.toml", + "clippy_utils/Cargo.toml", + "Cargo.toml", +]; + +pub fn bump_version() { + let (minor, mut patch) = clippy_version(); + patch += 1; + for file in &CARGO_TOML_FILES { + replace_region_in_file( + UpdateMode::Change, + Path::new(file), + "# begin autogenerated version\n", + "# end autogenerated version", + |res| { + writeln!(res, "version = \"0.{minor}.{patch}\"").unwrap(); + }, + ); + } +} |
