Re: [PATCH v2] hooks: propose project configured hooks
- From
Albert Cui <albertqcui@gmail.com>
- Date
- Apr 6, 2021, 00:27 UTC
- Message-ID
- <CAMbkP-Tamv6yt2CFp92UOK0SFZudXq71oX6ORPEY46n-gN=wdA@mail.gmail.com>
- In-Reply-To
- <xmqq7dlg46d6.fsf@gitster.g>
On Mon, Apr 5, 2021 at 5:14 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> > Albert Cui <albertqcui@gmail.com> writes: > > > I'm a little confused, and maybe it's because we have different > > definitions of what "installing hooks" means. By installing hooks, > > I meant the addition of the hook command to the config, e.g the > > outcome of: > > > > `git config --add hook.pre-commit.command pylint` > > Yeah, I was envisioning that it won't be as a simple, mechanical and > unconditional single command invocation. Rather, the 'pylint' part > would have to become different depending on the environment (e.g. > what operating system you are on, what editor you prefer, etc.). > And the part that decides what kind of environment you are on would > have to be written by the project that controls the "project-managed > hooks"---unfortunately that would most likely to be an error-prone > part. >
I don't see a need for that. At least, this doesn't feel part of the "minimum feature set."
I don't think any existing solutions for hooks management handle this, so it feels fine to push this part to the project. As you said, if they wanted this, I'd expect `git config --add hook.pre-commit.command lint.sh` where lint.sh does whatever cross-platform magic is required.
I wouldn't expect a lot of need for this anyway; I'd expect most hooks to depend on tools that already work cross-platform (e.g. pylint) or be hooks written in the programming environment of the project, so the toolchain should already be in place to execute the hooks.