2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Don't warn about subject line length for the fixup commits

The fixup commits' subject line has a prefix which has its own
length, so warning about the exceeding length is not accurate.
Given that the fixup commits can not be merged, because they
cause a danger failure, it's safe to ignore the length check
for them.
This commit is contained in:
Aram Sargsyan 2023-09-06 09:52:12 +00:00
parent faeffce4eb
commit 3db2beef9f

View File

@ -99,11 +99,13 @@ fixup_error_logged = False
for commit in danger.git.commits: for commit in danger.git.commits:
message_lines = commit.message.splitlines() message_lines = commit.message.splitlines()
subject = message_lines[0] subject = message_lines[0]
if not fixup_error_logged and ( is_merge = subject.startswith("Merge branch ")
is_fixup = (
subject.startswith("fixup!") subject.startswith("fixup!")
or subject.startswith("amend!") or subject.startswith("amend!")
or subject.startswith("Apply suggestion") or subject.startswith("Apply suggestion")
): )
if not fixup_error_logged and is_fixup:
fail( fail(
"Fixup commits are still present in this merge request. " "Fixup commits are still present in this merge request. "
"Please squash them before merging." "Please squash them before merging."
@ -115,7 +117,7 @@ for commit in danger.git.commits:
f"Prohibited keyword `{match.groups()[0]}` detected " f"Prohibited keyword `{match.groups()[0]}` detected "
f"at the start of a subject line in commit {commit.sha}." f"at the start of a subject line in commit {commit.sha}."
) )
if len(subject) > 72 and not subject.startswith("Merge branch "): if len(subject) > 72 and not is_merge and not is_fixup:
warn( warn(
f"Subject line for commit {commit.sha} is too long: " f"Subject line for commit {commit.sha} is too long: "
f"```{subject}``` ({len(subject)} > 72 characters)." f"```{subject}``` ({len(subject)} > 72 characters)."