-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
393 additions
and
9 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
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::new_lint::clippy_version; | ||
use crate::update_lints::{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=\"Sync from Clippy commit:\" 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}"); | ||
} |
Oops, something went wrong.