diff --git a/crates/committed/src/checks.rs b/crates/committed/src/checks.rs index 94f48d8..31d0021 100644 --- a/crates/committed/src/checks.rs +++ b/crates/committed/src/checks.rs @@ -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)?; } @@ -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() +} + const FIXUP_PREFIXES: [&str; 3] = ["fixup! ", "squash! ", "amend! "]; pub(crate) fn check_fixup( diff --git a/crates/committed/tests/cmd.rs b/crates/committed/tests/cmd.rs index 337ce9e..7d91fb5 100644 --- a/crates/committed/tests/cmd.rs +++ b/crates/committed/tests/cmd.rs @@ -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![]);