Skip to content

Commit

Permalink
fix: Skip allowed wip prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 19, 2024
1 parent 43267e5 commit 8d0dcd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions crates/committed/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub(crate) fn check_message(
if config.no_wip() {
failed |= check_wip(source, message, report)?;
}
message = strip_wip(message);
if config.no_fixup() {
failed |= check_fixup(source, message, report)?;
}
Expand Down Expand Up @@ -344,6 +345,15 @@ pub(crate) fn check_wip(
}
}

pub(crate) fn strip_wip(message: &str) -> &str {
let Some(c) = WIP_RE.captures(message) else {
return message;
};

let matched = c.get(0).unwrap();
&message[matched.len()..].trim_start()

Check warning

Code scanning / clippy

this expression creates a reference which is immediately dereferenced by the compiler Warning

this expression creates a reference which is immediately dereferenced by the compiler

Check warning

Code scanning / clippy

this expression creates a reference which is immediately dereferenced by the compiler Warning

this expression creates a reference which is immediately dereferenced by the compiler
}

const FIXUP_PREFIXES: [&str; 3] = ["fixup! ", "squash! ", "amend! "];

pub(crate) fn check_fixup(
Expand Down
2 changes: 1 addition & 1 deletion crates/committed/tests/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn wip_config_override() {
run_committed("wip bad times ahead", "no_wip = false")
.code(1)
.stdout_eq(str![[r#"
-: error Subject should be capitalized but found `wip`
-: error Subject should be capitalized but found `bad`
"#]])
.stderr_eq(str![]);
Expand Down

0 comments on commit 8d0dcd9

Please sign in to comment.