On 2019-05-19 at 06:03:11, Olegzandr von Denman (ORESoftware) wrote:
> I was expected an env var like:
> 
> GIT_DESIRED_COMMIT_MESSAGE
> 
> to show up when .git/hooks/pre-commit is run
> 
> but as described here, there doesn't appear to be any args to the
> script and the environment variable isn't there?
> 
> https://stackoverflow.com/questions/56205170/retrieving-desired-git-commit-message-in-pre-commit-hook

In general, the pre-commit hook isn't the right place to inspect the
commit message. If the user hasn't specified the commit message on the
command line, then they will be prompted for it using their editor, and
there will be nothing to process.

Furthermore, since the prepare-commit-msg hook hasn't run, there could
be arbitrary changes to the commit message after the pre-commit hook
runs. You'd want to use the prepare-commit-msg hook to modify the commit
message and then use the commit-msg hook to accept or reject it. Despite
the name, the commit-msg hook can be used to perform arbitrary analysis
of the commit and reject it for any reason if you require the commit
message to do so.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

Attachment: signature.asc
Description: PGP signature

Reply via email to