Skip to content

Commit

Permalink
Add --allow-no-vcs to cargo dev dogfood --fix (#14227)
Browse files Browse the repository at this point in the history
Some developers might prefer to use alternate VCS, such as Jujutsu,
which are not detected by `cargo fix`. This forwards the
`--allow-no-vcs` command line argument to `cargo fix`.

changelog: none
  • Loading branch information
flip1995 authored Feb 17, 2025
2 parents 0f20a12 + 6dd477a commit 1750411
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion clippy_dev/src/dogfood.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use std::process::Command;
/// # Panics
///
/// Panics if unable to run the dogfood test
pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
#[allow(clippy::fn_params_excessive_bools)]
pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool, allow_no_vcs: bool) {
let mut cmd = Command::new("cargo");

cmd.current_dir(clippy_project_root())
Expand All @@ -25,6 +26,10 @@ pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
dogfood_args.push("--allow-staged");
}

if allow_no_vcs {
dogfood_args.push("--allow-no-vcs");
}

cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" "));

exit_if_err(cmd.status());
Expand Down
6 changes: 5 additions & 1 deletion clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fn main() {
fix,
allow_dirty,
allow_staged,
} => dogfood::dogfood(fix, allow_dirty, allow_staged),
allow_no_vcs,
} => dogfood::dogfood(fix, allow_dirty, allow_staged, allow_no_vcs),
DevCommand::Fmt { check, verbose } => fmt::run(check, verbose),
DevCommand::UpdateLints { print_only, check } => {
if print_only {
Expand Down Expand Up @@ -106,6 +107,9 @@ enum DevCommand {
#[arg(long, requires = "fix")]
/// Fix code even if the working directory has staged changes
allow_staged: bool,
#[arg(long, requires = "fix")]
/// Fix code even if a VCS was not detected
allow_no_vcs: bool,
},
/// Run rustfmt on all projects and tests
Fmt {
Expand Down

0 comments on commit 1750411

Please sign in to comment.