summaryrefslogtreecommitdiffstats
path: root/gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py')
-rw-r--r--gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py22
1 files changed, 22 insertions, 0 deletions
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 []