def __init__(self): self.rules = RuleCollection(self.default_rule_classes) self._verbosity = options.IntOption('verbosity', 3, "Verbosity") self._ignore_merge_commits = options.BoolOption( 'ignore-merge-commits', True, "Ignore merge commits") self._ignore_fixup_commits = options.BoolOption( 'ignore-fixup-commits', True, "Ignore fixup commits") self._ignore_squash_commits = options.BoolOption( 'ignore-squash-commits', True, "Ignore squash commits") self._ignore_revert_commits = options.BoolOption( 'ignore-revert-commits', True, "Ignore revert commits") self._debug = options.BoolOption('debug', False, "Enable debug mode") self._extra_path = None target_description = "Path of the target git repository (default=current working directory)" self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description) self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore') self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable') self._config_path = None ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server." self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description) self._staged = options.BoolOption( 'staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self): # Use an ordered dict so that the order in which rules are applied is always the same self._rules = OrderedDict([(rule_cls.id, rule_cls()) for rule_cls in self.default_rule_classes]) self._verbosity = options.IntOption('verbosity', 3, "Verbosity") self._ignore_merge_commits = options.BoolOption( 'ignore-merge-commits', True, "Ignore merge commits") self._ignore_fixup_commits = options.BoolOption( 'ignore-fixup-commits', True, "Ignore fixup commits") self._ignore_squash_commits = options.BoolOption( 'ignore-squash-commits', True, "Ignore squash commits") self._debug = options.BoolOption('debug', False, "Enable debug mode") self._extra_path = None target_description = "Path of the target git repository (default=current working directory)" self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description) self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore') self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable') self._config_path = None ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server." self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
def test_contrib(self): config = LintConfig() contrib_rules = ["contrib-title-conventional-commits", "CC1"] config.set_general_option("contrib", ",".join(contrib_rules)) self.assertEqual(config.contrib, contrib_rules) # Check contrib-title-conventional-commits contrib rule actual_rule = config.rules.find_rule( "contrib-title-conventional-commits") self.assertTrue(actual_rule.is_contrib) self.assertEqual(ustr(type(actual_rule)), "<class 'conventional_commit.ConventionalCommit'>") self.assertEqual(actual_rule.id, 'CT1') self.assertEqual(actual_rule.name, u'contrib-title-conventional-commits') self.assertEqual(actual_rule.target, rules.CommitMessageTitle) expected_rule_option = options.ListOption( "types", [ "fix", "feat", "chore", "docs", "style", "refactor", "perf", "test", "revert" ], "Comma separated list of allowed commit types.", ) self.assertListEqual(actual_rule.options_spec, [expected_rule_option]) self.assertDictEqual(actual_rule.options, {'types': expected_rule_option}) # Check contrib-body-requires-signed-off-by contrib rule actual_rule = config.rules.find_rule( "contrib-body-requires-signed-off-by") self.assertTrue(actual_rule.is_contrib) self.assertEqual(ustr(type(actual_rule)), "<class 'signedoff_by.SignedOffBy'>") self.assertEqual(actual_rule.id, 'CC1') self.assertEqual(actual_rule.name, u'contrib-body-requires-signed-off-by') # reset value (this is a different code path) config.set_general_option("contrib", "contrib-body-requires-signed-off-by") self.assertEqual( actual_rule, config.rules.find_rule("contrib-body-requires-signed-off-by")) self.assertIsNone( config.rules.find_rule("contrib-title-conventional-commits")) # empty value config.set_general_option("contrib", "") self.assertListEqual(config.contrib, [])
def __init__(self): # Use an ordered dict so that the order in which rules are applied is always the same self._rules = OrderedDict([(rule_cls.id, rule_cls()) for rule_cls in self.default_rule_classes]) self._verbosity = options.IntOption('verbosity', 3, "Verbosity") self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits") self._debug = options.BoolOption('debug', False, "Enable debug mode") self._extra_path = None target_description = "Path of the target git repository (default=current working directory)" self._target = options.PathOption('target', os.path.abspath(os.getcwd()), target_description) self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore') self._config_path = None