From f3b6c222fb11c96e2f8bbaa0622f46c8ec486874 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 19 Nov 2022 15:52:50 +0100 Subject: Merging upstream version 0.18.0. Signed-off-by: Daniel Baumann --- .../contrib/rules/disallow_cleanup_commits.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py (limited to 'gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py') diff --git a/gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py b/gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py new file mode 100644 index 0000000..7f62dee --- /dev/null +++ b/gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py @@ -0,0 +1,22 @@ +from gitlint.rules import CommitRule, RuleViolation + + +class DisallowCleanupCommits(CommitRule): + """This rule checks the commits for "fixup!"/"squash!"/"amend!" commits + and rejects them. + """ + + name = "contrib-disallow-cleanup-commits" + id = "CC2" + + def validate(self, commit): + if commit.is_fixup_commit: + return [RuleViolation(self.id, "Fixup commits are not allowed", line_nr=1)] + + if commit.is_squash_commit: + return [RuleViolation(self.id, "Squash commits are not allowed", line_nr=1)] + + if commit.is_fixup_amend_commit: + return [RuleViolation(self.id, "Amend commits are not allowed", line_nr=1)] + + return [] -- cgit v1.2.3