本文整理匯總了Python中gitlint.config.LintConfig.apply_config_from_commit方法的典型用法代碼示例。如果您正苦於以下問題:Python LintConfig.apply_config_from_commit方法的具體用法?Python LintConfig.apply_config_from_commit怎麽用?Python LintConfig.apply_config_from_commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gitlint.config.LintConfig
的用法示例。
在下文中一共展示了LintConfig.apply_config_from_commit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_gitcontext_ignore_specific
# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import apply_config_from_commit [as 別名]
def test_gitcontext_ignore_specific(self):
# ignore specific rules
config = LintConfig()
context = self.gitcontext("test\ngitlint-ignore: T1, body-hard-tab")
config.apply_config_from_commit(context.commits[-1])
expected_rules = [rule for rule in config.rules if rule.id not in ["T1", "body-hard-tab"]]
self.assertEqual(config.rules, expected_rules)
示例2: test_lint_sample4
# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import apply_config_from_commit [as 別名]
def test_lint_sample4(self):
gitcontext = self.gitcontext(self.get_sample("commit_message/sample4"))
lintconfig = LintConfig()
lintconfig.apply_config_from_commit(gitcontext.commits[-1])
linter = GitLinter(lintconfig)
violations = linter.lint(gitcontext.commits[-1], gitcontext)
# expect no violations because sample4 has a 'gitlint: disable line'
expected = []
self.assertListEqual(violations, expected)
示例3: test_gitcontext_ignore_all
# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import apply_config_from_commit [as 別名]
def test_gitcontext_ignore_all(self):
config = LintConfig()
original_rules = config.rules
# nothing gitlint
context = self.gitcontext("test\ngitlint\nfoo")
config.apply_config_from_commit(context.commits[-1])
self.assertListEqual(config.rules, original_rules)
# ignore all rules
context = self.gitcontext("test\ngitlint-ignore: all\nfoo")
config.apply_config_from_commit(context.commits[-1])
self.assertEqual(config.rules, [])
# ignore all rules, no space
config = LintConfig()
context = self.gitcontext("test\ngitlint-ignore:all\nfoo")
config.apply_config_from_commit(context.commits[-1])
self.assertEqual(config.rules, [])
# ignore all rules, more spacing
config = LintConfig()
context = self.gitcontext("test\ngitlint-ignore: \t all\nfoo")
config.apply_config_from_commit(context.commits[-1])
self.assertEqual(config.rules, [])
示例4: test_lint_sample5
# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import apply_config_from_commit [as 別名]
def test_lint_sample5(self):
gitcontext = self.gitcontext(self.get_sample("commit_message/sample5"))
lintconfig = LintConfig()
lintconfig.apply_config_from_commit(gitcontext.commits[-1])
linter = GitLinter(lintconfig)
violations = linter.lint(gitcontext.commits[-1], gitcontext)
title = " Commit title containing 'WIP', \tleading and trailing whitespace and longer than 72 characters."
# expect only certain violations because sample5 has a 'gitlint: T3,'
expected = [RuleViolation("T1", "Title exceeds max length (95>72)", title, 1),
RuleViolation("T4", "Title contains hard tab characters (\\t)", title, 1),
RuleViolation("T5", "Title contains the word 'WIP' (case-insensitive)", title, 1),
RuleViolation("B4", "Second line is not empty", "This line should be empty", 2),
RuleViolation("B2", "Line has trailing whitespace",
"This line has a trailing space. ", 4),
RuleViolation("B2", "Line has trailing whitespace", "This line has a trailing tab.\t",
5),
RuleViolation("B3", "Line contains hard tab characters (\\t)",
"This line has a trailing tab.\t", 5)]
self.assertListEqual(violations, expected)