[Insight-developers] Commit message prefix hook. Why was this pushaccepted?

Luis Ibanez luis.ibanez at kitware.com
Sun Nov 28 16:48:36 EST 2010


Bill,

There are two major types of hooks:

http://progit.org/book/ch7-3.html

a) Client hooks
b) Server hooks

"The client-side hooks are for client operations such as committing and
merging."

The client hooks are in the typically in the directory:

        project/.git/hooks

but our setup script

    Utilities/DevelopmentSetupScripts/SetupHooks.sh

configure them to be in

    ITK/Utilities/Hooks

lines 66, 67:

git config hooks.chain-prepare-commit-msg Utilities/Hooks/prepare-commit-msg
git config hooks.chain-commit-msg Utilities/Hooks/commit-msg


These two scripts are explained in:

http://progit.org/book/ch7-3.html


   - pre-commit
   - prepare-commit-msg
   - commit-msg
   - post-commit



"The pre-commit hook is run first, before you even type in a commit message.
It’s used to inspect the snapshot that’s about to be committed, to see if
you’ve forgotten something, to make sure tests run, or to examine whatever
you need to inspect in the code."

"The prepare-commit-msg hook is run before the commit message editor is
fired up but after the default message is created. It lets you edit the
default message before the commit author sees it. This hook takes a few
options: the path to the file that holds the commit message so far, the type
of commit, and the commit SHA-1 if this is an amended commit. This hook
generally isn’t useful for normal commits; rather, it’s good for commits
where the default message is auto-generated, such as templated commit
messages, merge commits, squashed commits, and amended commits. You may use
it in conjunction with a commit template to programmatically insert
information."

"The commit-msg hook takes one parameter, which again is the path to a
temporary file that contains the current commit message. 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.
In the last section of this chapter, I’ll demonstrate using this hook to
check that your commit message is conformant to a required pattern."

"After the entire commit process is completed, the post-commit hook runs. It
doesn’t take any parameters, but you can easily get the last commit by
running git log -1 HEAD. Generally, this script is used for notification or
something similar."
"Other Client HooksFinally, the post-merge hook runs after a successful
merge command. You can use it to restore data in the working tree that Git
can’t track, such as permissions data. This hook can likewise validate the
presence of files external to Git control that you may want copied in when
the working tree changes."


--------


In summary:


The hooks that we are using are
run at commit time in the local
repository of the developer.




   Luis

----------------------------------------------------------
On Sun, Nov 28, 2010 at 1:57 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:

> But shouldn't the merge be refused? I guess I don't understand how the
> commit hooks work.
>
>
> On Sun, Nov 28, 2010 at 12:50 PM, Hans Johnson <hans-johnson at uiowa.edu>
> wrote:
> > Much of this happed because this patch-set was dormant for two weeks.
>  The
> > commit message prefix hooks were added after the patch-set was submitted
> to
> > Gerrit.
> >
> > Hans
> >
> >
> > On 11/28/10 11:28 AM, "Bill Lorensen" <bill.lorensen at gmail.com> wrote:
> >
> >> Folks,
> >>
> >> This gerrit topic:
> >> http://review.source.kitware.com/#change,355
> >> was successfully merged.
> >>
> >> Yet, it's commit message prefix does not conform to the ITK convention.
> >>
> >> How did this happen?
> >>
> >> Also since this adds a new base capability to ITK, 13 reviewers were
> >> requested, yet only 5 reviewers responded, and onl;y 2 approved.
> >>
> >> Bill
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Kitware offers ITK Training Courses, for more information visit:
> >> http://kitware.com/products/protraining.html
> >>
> >> Please keep messages on-topic and check the ITK FAQ at:
> >> http://www.itk.org/Wiki/ITK_FAQ
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.itk.org/mailman/listinfo/insight-developers
> >
> > --
> > Hans J. Johnson, Ph.D.
> > Assistant Professor
> > 200 Hawkins Drive
> > T205 BT, The University of Iowa
> > Iowa City, IA 52242
> >
> > hans-johnson at uiowa.edu
> > PHONE: 319 353 8587
> >
> >
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20101128/a481b3cf/attachment.htm>


More information about the Insight-developers mailing list