Re: Pre-commit hook assistance

On 30.08.2019 15:01, William Muriithi wrote:
> Morning,
>
> I am attempting to write a pre-commit hook that enforces a policy to
> some group and warns the rest of the team. The hook is in python and
> it just check that jira ticket exist on the commit log.
>
> The problem I am facing is I am not able to both warn and error for
> some reason. If I exit, the failure reason is displayed to the user.
>
> If I don't exit, but attempts to send a warning to the client,
> nothing show up even in the logs.
>
> I am using sys.stderr.write and sys.stdout.write for error and warning
> respectively. Is it technically possible to do this? Would be grateful
> for your help on this.

This is clearly documented in the pre-commit hook template:

# If the hook program exits with success, the txn is committed; but
# if it exits with failure (non-zero), the txn is aborted, no commit
# takes place, and STDERR is returned to the client.

So, no, you can't send "warnings" by writing to stdout, and stderr is
only piped to the client if the hook fails.