def generate_config(ctx): """ Generates a sample gitlint config file. """ path = click.prompt('Please specify a location for the sample gitlint config file', default=DEFAULT_CONFIG_FILE) path = os.path.abspath(path) dir_name = os.path.dirname(path) if not os.path.exists(dir_name): click.echo(u"Error: Directory '{0}' does not exist.".format(dir_name), err=True) ctx.exit(USAGE_ERROR_CODE) elif os.path.exists(path): click.echo(u"Error: File \"{0}\" already exists.".format(path), err=True) ctx.exit(USAGE_ERROR_CODE) LintConfigGenerator.generate_config(path) click.echo(u"Successfully generated {0}".format(path)) ctx.exit(0)
def generate_config(ctx): """ Generates a sample gitlint config file. """ path = click.prompt('Please specify a location for the sample gitlint config file', default=DEFAULT_CONFIG_FILE) path = os.path.abspath(path) dir_name = os.path.dirname(path) if not os.path.exists(dir_name): click.echo("Error: Directory '{0}' does not exist.".format(dir_name), err=True) ctx.exit(USAGE_ERROR_CODE) elif os.path.exists(path): click.echo("Error: File \"{0}\" already exists.".format(path), err=True) ctx.exit(USAGE_ERROR_CODE) LintConfigGenerator.generate_config(path) click.echo("Successfully generated {0}".format(path)) ctx.exit(0)
def test_config_equality(self): self.assertEqual(LintConfig(), LintConfig()) self.assertNotEqual(LintConfig(), LintConfigGenerator()) # Ensure LintConfig are not equal if they differ on their attributes attrs = [("verbosity", 1), ("rules", []), ("ignore_stdin", True), ("debug", True), ("ignore", ["T1"]), ("staged", True), ("_config_path", self.get_sample_path()), ("ignore_merge_commits", False), ("ignore_fixup_commits", False), ("ignore_squash_commits", False), ("ignore_revert_commits", False), ("extra_path", self.get_sample_path("user_rules")), ("target", self.get_sample_path()), ("contrib", ["CC1"])] for attr, val in attrs: config = LintConfig() setattr(config, attr, val) self.assertNotEqual(LintConfig(), config) # Other attributes don't matter config1 = LintConfig() config2 = LintConfig() config1.foo = u"bår" self.assertEqual(config1, config2) config2.foo = u"dūr" self.assertEqual(config1, config2)
def test_install_commit_msg_hook_negative(copy): LintConfigGenerator.generate_config(u"föo/bar/test") copy.assert_called_with(GITLINT_CONFIG_TEMPLATE_SRC_PATH, u"föo/bar/test")
def test_install_commit_msg_hook_negative(copy): LintConfigGenerator.generate_config("foo/bar/test") copy.assert_called_with(GITLINT_CONFIG_TEMPLATE_SRC_PATH, "foo/bar/test")