Skip to content

Commit

Permalink
Merge pull request #395 from JP-Ellis/feat/autosquash
Browse files Browse the repository at this point in the history
feat: check all autosquash messages
  • Loading branch information
epage authored Dec 19, 2024
2 parents 71a6c60 + 30ff2c6 commit 79254d6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions crates/committed/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,17 @@ pub(crate) fn check_wip(
}
}

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

pub(crate) fn check_fixup(
source: report::Source<'_>,
message: &str,
report: report::Report,
) -> Result<bool, anyhow::Error> {
if message.starts_with(FIXUP_PREFIX) {
if FIXUP_PREFIXES
.iter()
.any(|prefix| message.starts_with(prefix))
{
report(report::Message::error(source, report::Fixup {}));
Ok(true)
} else {
Expand All @@ -358,15 +363,14 @@ pub(crate) fn check_fixup(
}

pub(crate) fn strip_fixup(message: &str) -> &str {
if let Some(message) = message.strip_prefix(FIXUP_PREFIX) {
message
} else {
message
for prefix in FIXUP_PREFIXES.iter() {
if let Some(message) = message.strip_prefix(prefix) {
return message;
}
}
message
}

const FIXUP_PREFIX: &str = "fixup! ";

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

0 comments on commit 79254d6

Please sign in to comment.