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 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 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")