Re: [PATCH 8/9] hook: teach 'hookcmd' config to alias hook scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 15 2021, Emily Shaffer wrote:

> To enable fine-grained options which apply to a single hook executable,
> and to make it easier for a single executable to be run on multiple hook
> events, teach "hookcmd.<alias>.config". These can be configured as
> follows:
> [...]
> diff --git a/Documentation/config/hook.txt b/Documentation/config/hook.txt
> index a97b980cca..5b35170664 100644
> --- a/Documentation/config/hook.txt
> +++ b/Documentation/config/hook.txt
> @@ -3,6 +3,11 @@ hook.<command>.command::
>  	executable on your device, a oneliner for your shell, or the name of a
>  	hookcmd. See linkgit:git-hook[1].
>  
> +hookcmd.<name>.command::
> +	A command to execute during a hook for which <name> has been specified
> +	as a command. This can be an executable on your device or a oneliner for
> +	your shell. See linkgit:git-hook[1].
> +
> [...]
> +Global config
> +----
> +  [hook "post-commit"]
> +    command = "linter"
> +    command = "~/typocheck.sh"
> +
> +  [hookcmd "linter"]
> +    command = "/bin/linter --c"
> +----
> +
> +Local config
> +----
> +  [hook "prepare-commit-msg"]
> +    command = "linter"
> +  [hook "post-commit"]
> +    command = "python ~/run-test-suite.py"
> +----
> +
> +With these configs, you'd then run post-commit hooks in this order:
> +
> +  /bin/linter --c
> +  ~/typocheck.sh
> +  python ~/run-test-suite.py
> +  .git/hooks/post-commit (if present)
> +
> +and prepare-commit-msg hooks in this order:
> +
> +  /bin/linter --c
> +  .git/hooks/prepare-commit-msg (if present)
>  

I still have outstanding feedback on the fundamental design
here. I.e. why is this not:

    hook.<name>.event = post-commit
    hook.<name>.command = <path>

See:

https://lore.kernel.org/git/87mtv8fww3.fsf@xxxxxxxxxxxxxxxxxxx/

As noted there I don't see why not, and more complexity results from the
design choice of doing it the way you're proposing. I.e. we can't
discover hooks based on config prefixes, and we end up sticking full FS
paths in config keys.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux