本文整理汇总了Python中gitlint.config.LintConfig.apply_config_from_gitcontext方法的典型用法代码示例。如果您正苦于以下问题:Python LintConfig.apply_config_from_gitcontext方法的具体用法?Python LintConfig.apply_config_from_gitcontext怎么用?Python LintConfig.apply_config_from_gitcontext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitlint.config.LintConfig
的用法示例。
在下文中一共展示了LintConfig.apply_config_from_gitcontext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gitcontext_ignore_specific
# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import apply_config_from_gitcontext [as 别名]
def test_gitcontext_ignore_specific(self):
# ignore specific rules
config = LintConfig()
context = GitContext()
context.set_commit_msg("test\ngitlint-ignore: T1, body-hard-tab")
config.apply_config_from_gitcontext(context)
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_gitcontext [as 别名]
def test_lint_sample4(self):
gitcontext = GitContext()
gitcontext.set_commit_msg(self.get_sample("commit_message/sample4"))
lintconfig = LintConfig()
lintconfig.apply_config_from_gitcontext(gitcontext)
linter = GitLinter(lintconfig)
violations = linter.lint(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_gitcontext [as 别名]
def test_gitcontext_ignore_all(self):
config = LintConfig()
original_rules = config.rules
# nothing gitlint
context = GitContext()
context.set_commit_msg("test\ngitlint\nfoo")
config.apply_config_from_gitcontext(context)
self.assertListEqual(config.rules, original_rules)
# ignore all rules
context = GitContext()
context.set_commit_msg("test\ngitlint-ignore: all\nfoo")
config.apply_config_from_gitcontext(context)
self.assertEqual(config.rules, [])
# ignore all rules, no space
config = LintConfig()
context.set_commit_msg("test\ngitlint-ignore:all\nfoo")
config.apply_config_from_gitcontext(context)
self.assertEqual(config.rules, [])
# ignore all rules, more spacing
config = LintConfig()
context.set_commit_msg("test\ngitlint-ignore: \t all\nfoo")
config.apply_config_from_gitcontext(context)
self.assertEqual(config.rules, [])
示例4: test_lint_sample5
# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import apply_config_from_gitcontext [as 别名]
def test_lint_sample5(self):
gitcontext = GitContext()
gitcontext.set_commit_msg(self.get_sample("commit_message/sample5"))
lintconfig = LintConfig()
lintconfig.apply_config_from_gitcontext(gitcontext)
linter = GitLinter(lintconfig)
violations = linter.lint(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)