forked from rust-lang/rust-clippy
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement release subcommand in clippy_dev
This is a QoL improvement for doing releases. The `release bump_version` subcommand increments the version in all relevant `Cargo.toml` files. The `release commit` command will only work with the new Josh syncs. Until then the old way, using `git log` has to be used.
- Loading branch information
Showing
9 changed files
with
116 additions
and
1 deletion.
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
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
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,76 @@ | ||
use std::fmt::{Display, Write}; | ||
use std::path::Path; | ||
|
||
use crate::sync::PUSH_PR_DESCRIPTION; | ||
use crate::utils::{clippy_version, replace_region_in_file, UpdateMode}; | ||
|
||
use clap::ValueEnum; | ||
use xshell::{cmd, Shell}; | ||
|
||
const CARGO_TOML_FILES: [&str; 5] = [ | ||
"clippy_config/Cargo.toml", | ||
"clippy_lints/Cargo.toml", | ||
"clippy_utils/Cargo.toml", | ||
"declare_clippy_lint/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(); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
#[derive(ValueEnum, Copy, Clone)] | ||
pub enum Branch { | ||
Stable, | ||
Beta, | ||
Master, | ||
} | ||
|
||
impl Display for Branch { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Branch::Stable => write!(f, "stable"), | ||
Branch::Beta => write!(f, "beta"), | ||
Branch::Master => write!(f, "master"), | ||
} | ||
} | ||
} | ||
|
||
pub fn rustc_clippy_commit(rustc_path: String, branch: Branch) { | ||
let sh = Shell::new().expect("failed to create shell"); | ||
sh.change_dir(rustc_path); | ||
|
||
let base = branch.to_string(); | ||
cmd!(sh, "git fetch https://github.com/rust-lang/rust {base}") | ||
.run() | ||
.expect("failed to fetch base commit"); | ||
let last_rustup_commit = cmd!( | ||
sh, | ||
"git log -1 --merges --grep=\"{PUSH_PR_DESCRIPTION}\" FETCH_HEAD -- src/tools/clippy" | ||
) | ||
.read() | ||
.expect("failed to run git log"); | ||
|
||
let commit = last_rustup_commit | ||
.lines() | ||
.find(|c| c.contains("Sync from Clippy commit:")) | ||
.expect("no commit found") | ||
.trim() | ||
.rsplit_once('@') | ||
.expect("no commit hash found") | ||
.1; | ||
|
||
println!("{commit}"); | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[toolchain] | ||
# begin autogenerated version | ||
channel = "nightly-2024-05-02" | ||
# end autogenerated version | ||
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] |