git hooks bash -- getting the commit message -


i writing git hook, run on commit main branch. need parse , text in the commit message. how reference commit message in bash script?

also know how run hook on commits main branch. developers can quash there local commits , commit main branch when have fixed bug or something.

please , thank you.

the answer depends on you're trying commit message. there 3 hooks asking about:

  • prepare-commit-msg run after default message prepared, before user edits it. first argument name of file commit message. (the second argument indicates message came from.)

  • commit-msg run after commit message edited/finalized, before commit takes place. if want fail commit if user's commit message bad, or modify message, want this, , single argument name of file commit message.

  • post-commit run after commit. has no arguments, can of course message git log -n 1 head (probably --format=format:%s%n%b or such). if want in message, , notify based on it, should use this.

all of material taken githooks manpage

as running on main branch, need like:

if [ "$(git symbolic-ref head)" == "refs/head/master" ];     # stuff fi 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -