Skip to content

Commit 93d5ccd

Browse files
committed
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.
1 parent 6671553 commit 93d5ccd

File tree

7 files changed

+55
-1
lines changed

7 files changed

+55
-1
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
22
name = "clippy"
3+
# begin autogenerated version
34
version = "0.1.84"
5+
# end autogenerated version
46
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
57
repository = "https://github.com/rust-lang/rust-clippy"
68
readme = "README.md"

clippy_config/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
22
name = "clippy_config"
3+
# begin autogenerated version
34
version = "0.1.84"
5+
# end autogenerated version
46
edition = "2021"
57
publish = false
68

clippy_dev/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub mod dogfood;
1818
pub mod fmt;
1919
pub mod lint;
2020
pub mod new_lint;
21+
pub mod release;
2122
pub mod serve;
2223
pub mod setup;
2324
pub mod sync;

clippy_dev/src/main.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![warn(rust_2018_idioms, unused_lifetimes)]
44

55
use clap::{Args, Parser, Subcommand};
6-
use clippy_dev::{dogfood, fmt, lint, new_lint, serve, setup, sync, update_lints, utils};
6+
use clippy_dev::{dogfood, fmt, lint, new_lint, release, serve, setup, sync, update_lints, utils};
77
use std::convert::Infallible;
88

99
fn main() {
@@ -78,6 +78,9 @@ fn main() {
7878
DevCommand::Sync(SyncCommand { subcommand }) => match subcommand {
7979
SyncSubcommand::UpdateNightly => sync::update_nightly(),
8080
},
81+
DevCommand::Release(ReleaseCommand { subcommand }) => match subcommand {
82+
ReleaseSubcommand::BumpVersion => release::bump_version(),
83+
},
8184
}
8285
}
8386

@@ -230,6 +233,8 @@ enum DevCommand {
230233
},
231234
/// Sync between the rust repo and the Clippy repo
232235
Sync(SyncCommand),
236+
/// Manage Clippy releases
237+
Release(ReleaseCommand),
233238
}
234239

235240
#[derive(Args)]
@@ -309,3 +314,16 @@ enum SyncSubcommand {
309314
/// Update nightly version in rust-toolchain and `clippy_utils`
310315
UpdateNightly,
311316
}
317+
318+
#[derive(Args)]
319+
struct ReleaseCommand {
320+
#[command(subcommand)]
321+
subcommand: ReleaseSubcommand,
322+
}
323+
324+
#[derive(Subcommand)]
325+
enum ReleaseSubcommand {
326+
#[command(name = "bump_version")]
327+
/// Bump the version in the Cargo.toml files
328+
BumpVersion,
329+
}

clippy_dev/src/release.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use std::fmt::Write;
2+
use std::path::Path;
3+
4+
use crate::utils::{UpdateMode, clippy_version, replace_region_in_file};
5+
6+
const CARGO_TOML_FILES: [&str; 4] = [
7+
"clippy_config/Cargo.toml",
8+
"clippy_lints/Cargo.toml",
9+
"clippy_utils/Cargo.toml",
10+
"Cargo.toml",
11+
];
12+
13+
pub fn bump_version() {
14+
let (minor, mut patch) = clippy_version();
15+
patch += 1;
16+
for file in &CARGO_TOML_FILES {
17+
replace_region_in_file(
18+
UpdateMode::Change,
19+
Path::new(file),
20+
"# begin autogenerated version\n",
21+
"# end autogenerated version",
22+
|res| {
23+
writeln!(res, "version = \"0.{minor}.{patch}\"").unwrap();
24+
},
25+
);
26+
}
27+
}

clippy_lints/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
22
name = "clippy_lints"
3+
# begin autogenerated version
34
version = "0.1.84"
5+
# end autogenerated version
46
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
57
repository = "https://github.com/rust-lang/rust-clippy"
68
readme = "README.md"

clippy_utils/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
22
name = "clippy_utils"
3+
# begin autogenerated version
34
version = "0.1.84"
5+
# end autogenerated version
46
edition = "2021"
57
description = "Helpful tools for writing lints, provided as they are used in Clippy"
68
repository = "https://github.com/rust-lang/rust-clippy"

0 commit comments

Comments
 (0)