Skip to content

Commit

Permalink
Merge pull request #397 from JP-Ellis/feat/strip-fixup
Browse files Browse the repository at this point in the history
feat: strip prefix
  • Loading branch information
epage authored Dec 18, 2024
2 parents 8ac2dfd + 724f1b8 commit 50e77c4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions crates/committed/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use committed::Style;

pub(crate) fn check_message(
source: report::Source<'_>,
message: &str,
mut message: &str,
config: &crate::config::Config,
report: report::Report,
) -> Result<bool, anyhow::Error> {
Expand All @@ -19,6 +19,7 @@ pub(crate) fn check_message(
}
if config.no_fixup() {
failed |= check_fixup(source, message, report)?;
message = strip_fixup(message);
}
// Bail out due to above checks
if failed {
Expand Down Expand Up @@ -348,14 +349,24 @@ pub(crate) fn check_fixup(
message: &str,
report: report::Report,
) -> Result<bool, anyhow::Error> {
if message.starts_with("fixup! ") {
if message.starts_with(FIXUP_PREFIX) {
report(report::Message::error(source, report::Fixup {}));
Ok(true)
} else {
Ok(false)
}
}

pub(crate) fn strip_fixup(message: &str) -> &str {
if let Some(message) = message.strip_prefix(FIXUP_PREFIX) {
message
} else {
message
}
}

const FIXUP_PREFIX: &str = "fixup! ";

pub(crate) fn check_merge_commit(
source: report::Source<'_>,
commit: &git2::Commit<'_>,
Expand Down

0 comments on commit 50e77c4

Please sign in to comment.