From 93db18e9721749ad9167da5271c6c49d049125ce Mon Sep 17 00:00:00 2001 From: Alzbeta Kucerova Date: Fri, 15 Aug 2025 12:21:05 +0200 Subject: [PATCH] Add documentation regarding new functionality of packit init Documentation now describes new requirements connected to the functionality that automatically adds packit-specific pre-commit check that validates .packit.yaml. Requirements are: 1. Working directory be a git repo 2. Pre-commit configuration file must be present A new flag was also added, which causes packit init to automatically create pre-commit configuration file in case it is missing. --- docs/cli/init.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/cli/init.md b/docs/cli/init.md index 5c7a97c75b..7199b6efba 100644 --- a/docs/cli/init.md +++ b/docs/cli/init.md @@ -7,7 +7,13 @@ sidebar_position: 3 Initiate a repository to start using packit. By default this command adds `.packit.yaml` config file to the git repository in the current working -directory. +directory. + +If a `.pre-commit-config.yaml` file is found at the root of the git repository, `init` will add a pre-commit hook, which automatically runs `packit config validate` to check the validity of `.packit.yaml` upon pre-commit. Before adding this hook, `init` also checks for the presence of a `.git` repo. This behavior can be disabled using the `--without-precommit` flag. + +In case `.pre-commit-config.yaml` is not found at the root of the repository, this behavior is skipped and can be forced using the `--force-precommit` flag. Please note that the +two listed flags `--without-precommit` and `--force-precommit` are mutually exclusive. + If a spec file is found in the git repository, `init` will set [specfile_path](/docs/configuration/#specfile_path) to point to it in `.packit.yaml`. Otherwise, `specfile_path` is set to `.spec`. @@ -25,5 +31,7 @@ initialize a [source-git repo](/source-git). source-git repo. Options: - -f, --force Reset config to default if already exists. - -h, --help Show this message and exit. + --force-precommit Automatically create an empty pre-commit configuration file if missing. + --without-precommit Skip adding pre-commit hook to pre-commit configuration file. + -f, --force Reset config to default if already exists. + -h, --help Show this message and exit.