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.
This commit is contained in:
Philipp Krones 2024-11-15 21:12:30 +01:00
parent 66715532ab
commit 93d5ccdba7
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
7 changed files with 55 additions and 1 deletions

View file

@ -1,6 +1,8 @@
[package] [package]
name = "clippy" name = "clippy"
# begin autogenerated version
version = "0.1.84" version = "0.1.84"
# end autogenerated version
description = "A bunch of helpful lints to avoid common pitfalls in Rust" description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy" repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md" readme = "README.md"

View file

@ -1,6 +1,8 @@
[package] [package]
name = "clippy_config" name = "clippy_config"
# begin autogenerated version
version = "0.1.84" version = "0.1.84"
# end autogenerated version
edition = "2021" edition = "2021"
publish = false publish = false

View file

@ -18,6 +18,7 @@ pub mod dogfood;
pub mod fmt; pub mod fmt;
pub mod lint; pub mod lint;
pub mod new_lint; pub mod new_lint;
pub mod release;
pub mod serve; pub mod serve;
pub mod setup; pub mod setup;
pub mod sync; pub mod sync;

View file

@ -3,7 +3,7 @@
#![warn(rust_2018_idioms, unused_lifetimes)] #![warn(rust_2018_idioms, unused_lifetimes)]
use clap::{Args, Parser, Subcommand}; 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; use std::convert::Infallible;
fn main() { fn main() {
@ -78,6 +78,9 @@ fn main() {
DevCommand::Sync(SyncCommand { subcommand }) => match subcommand { DevCommand::Sync(SyncCommand { subcommand }) => match subcommand {
SyncSubcommand::UpdateNightly => sync::update_nightly(), 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 between the rust repo and the Clippy repo
Sync(SyncCommand), Sync(SyncCommand),
/// Manage Clippy releases
Release(ReleaseCommand),
} }
#[derive(Args)] #[derive(Args)]
@ -309,3 +314,16 @@ enum SyncSubcommand {
/// Update nightly version in rust-toolchain and `clippy_utils` /// Update nightly version in rust-toolchain and `clippy_utils`
UpdateNightly, 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,
}

27
clippy_dev/src/release.rs Normal file
View file

@ -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();
},
);
}
}

View file

@ -1,6 +1,8 @@
[package] [package]
name = "clippy_lints" name = "clippy_lints"
# begin autogenerated version
version = "0.1.84" version = "0.1.84"
# end autogenerated version
description = "A bunch of helpful lints to avoid common pitfalls in Rust" description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy" repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md" readme = "README.md"

View file

@ -1,6 +1,8 @@
[package] [package]
name = "clippy_utils" name = "clippy_utils"
# begin autogenerated version
version = "0.1.84" version = "0.1.84"
# end autogenerated version
edition = "2021" edition = "2021"
description = "Helpful tools for writing lints, provided as they are used in Clippy" description = "Helpful tools for writing lints, provided as they are used in Clippy"
repository = "https://github.com/rust-lang/rust-clippy" repository = "https://github.com/rust-lang/rust-clippy"