summaryrefslogtreecommitdiffstats
path: root/gitlint/tests/rules/test_configuration_rules.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-10-13 05:34:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-10-13 05:34:57 +0000
commite2d38cd54491535f409372393baeed787c77388d (patch)
treee9f823c384ee487d30de5ae84c8d3755f6974baa /gitlint/tests/rules/test_configuration_rules.py
parentReleasing debian version 0.15.1-3. (diff)
downloadgitlint-e2d38cd54491535f409372393baeed787c77388d.tar.xz
gitlint-e2d38cd54491535f409372393baeed787c77388d.zip
Merging upstream version 0.16.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--gitlint/tests/rules/test_configuration_rules.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/gitlint/tests/rules/test_configuration_rules.py b/gitlint/tests/rules/test_configuration_rules.py
index 479d9c2..9302da5 100644
--- a/gitlint/tests/rules/test_configuration_rules.py
+++ b/gitlint/tests/rules/test_configuration_rules.py
@@ -71,6 +71,39 @@ class ConfigurationRuleTests(BaseTestCase):
"Commit message line ' a relëase body' matches the regex '(.*)relëase(.*)', ignoring rules: T1,B2"
self.assert_log_contains(expected_log_message)
+ def test_ignore_by_author_name(self):
+ commit = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line", author_name="Tëst nåme")
+
+ # No regex specified -> Config shouldn't be changed
+ rule = rules.IgnoreByAuthorName()
+ config = LintConfig()
+ rule.apply(config, commit)
+ self.assertEqual(config, LintConfig())
+ self.assert_logged([]) # nothing logged -> nothing ignored
+
+ # Matching regex -> expect config to ignore all rules
+ rule = rules.IgnoreByAuthorName({"regex": "(.*)ëst(.*)"})
+ expected_config = LintConfig()
+ expected_config.ignore = "all"
+ rule.apply(config, commit)
+ self.assertEqual(config, expected_config)
+
+ expected_log_message = ("DEBUG: gitlint.rules Ignoring commit because of rule 'I4': "
+ "Commit Author Name 'Tëst nåme' matches the regex '(.*)ëst(.*)',"
+ " ignoring rules: all")
+ self.assert_log_contains(expected_log_message)
+
+ # Matching regex with specific ignore
+ rule = rules.IgnoreByAuthorName({"regex": "(.*)nåme", "ignore": "T1,B2"})
+ expected_config = LintConfig()
+ expected_config.ignore = "T1,B2"
+ rule.apply(config, commit)
+ self.assertEqual(config, expected_config)
+
+ expected_log_message = ("DEBUG: gitlint.rules Ignoring commit because of rule 'I4': "
+ "Commit Author Name 'Tëst nåme' matches the regex '(.*)nåme', ignoring rules: T1,B2")
+ self.assert_log_contains(expected_log_message)
+
def test_ignore_body_lines(self):
commit1 = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line")
commit2 = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line")