当前位置: 首页>>代码示例>>Python>>正文


Python LintConfig.apply_config_from_commit方法代码示例

本文整理汇总了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)
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:9,代码来源:test_config.py

示例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)
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:11,代码来源:test_lint.py

示例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, [])
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:27,代码来源:test_config.py

示例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)
开发者ID:cimarron-pistoncloud,项目名称:gitlint,代码行数:21,代码来源:test_lint.py


注:本文中的gitlint.config.LintConfig.apply_config_from_commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。