Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the hook parameters passed to external hook program/script?

The title says it: I am looking for the variable names (HG_*) so I can make use of them in my hook script..

like image 757
Bonefisher Avatar asked Feb 07 '11 19:02

Bonefisher


People also ask

Where are Git hooks executed?

All Git hooks are ordinary scripts that Git executes when certain events occur in the repository. This makes them very easy to install and configure. Hooks can reside in either local or server-side repositories, and they are only executed in response to actions in that repository.

What are hooks in Python?

A hook can tell about additional source files or data files to import, or files not to import. A hook file is a Python script, and can use all Python features. It can also import helper methods from PyInstaller. utils. hooks and useful variables from PyInstaller.

What are Git hooks used for?

Git hooks are shell scripts found in the hidden . git/hooks directory of a Git repository. These scripts trigger actions in response to specific events, so they can help you automate your development lifecycle. Although you may never have noticed them, every Git repository includes 12 sample scripts.

What type of Git hook could be used to validate that a commit message contains a ticket number?

The commit-msg hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer. If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through.


2 Answers

Oben has your best answer, but for specific cases or poorly documented options you can easily test specific hooks using a hook that just prints variables:

hg --config hooks.pre-commit="export| grep HG_" commit

Where pre-commit can be any hook you want to test and commit can be any command you want to test.

For example that one showed:

export HG_ARGS='commit'
export HG_OPTS='{'"'"'exclude'"'"': [], '"'"'message'"'"': '"''"', '"'"'addremove'"'"': None, '"'"'include'"'"': [], '"'"'close_branch'"'"': None, '"'"'user'"'"': '"''"', '"'"'date'"'"': '"''"', '"'"'logfile'"'"': '"''"', '"'"'mq'"'"': None}'
export HG_PATS='[]'
like image 71
Ry4an Brase Avatar answered Sep 24 '22 02:09

Ry4an Brase


The hooks section in the hgrc manpage lists all defined hooks, including the environment variables available for each hook.

like image 37
Oben Sonne Avatar answered Sep 24 '22 02:09

Oben Sonne