git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Eugene Sajine <euguess@gmail.com>, Junio C Hamano <gitster@pobox.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: RE: global hooks - once again
Date: Mon, 5 Jul 2010 12:03:40 +0200	[thread overview]
Message-ID: <A612847CFE53224C91B23E3A5B48BAC744940F6E57@xmail3.se.axis.com> (raw)
In-Reply-To: <AANLkTikMEDUI7d5Mzwm8r43zCYTqefyI06PHOMvT1iLz@mail.gmail.com>

> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Eugene Sajine
> Sent: den 2 juli 2010 21:48
> To: Junio C Hamano
> Cc: git@vger.kernel.org
> Subject: Re: global hooks - once again
> 
> On Fri, Jul 2, 2010 at 3:18 PM, Junio C Hamano <gitster@pobox.com>
> wrote:
> > Eugene Sajine <euguess@gmail.com> writes:
> >
> >> For example, so i could say
> >> $ git config --global hooks.dir ~/git/hooks
> >
> > I don't think "global" hooks are useful for people who work on 
> > more than one project, or people who interact in more than one 
> > ways to projects.
> > Different projects typically have different needs out of the hooks
> > (e.g. pre-commit policy), and different workflows typically call 
> > for different needs out of the hooks (e.g. I would want to be able 
> > to rebase in my private working repository but not in the repository 
> > I use for integration of other people's branches).
> >
> > So I am fairly negative on your particular example above.
> 
> Well, you forgot about another half of users that are working with
> many projects but using one policy for example in one company, or if
> the guy works with several projects, but wants some of his custom
> hooks to be applied for all his repos/projects, for example if he want
> some general actions to be executed before commit, like spell check of
> the commit message. If I have 40 repos --global approach is the way to
> go.

Well, I belong to this secondary category, working for a company 
which is about to switch to git. Once the transition is completed,
we will have more than 800 git repositories, and they should all 
have a basic set of hooks (e.g., commit message validation, 
permissions checking, mail sending). Making our 100+ developers 
manually set up the hooks for each repository they clone is not an 
option.

So what I have done is setup a template directory with hooks being
a link to a pre-installed directory, where each hook is linked to a 
single script. This script then reads from a directory called 
hooks.d which is a drop directory for hooks. Each hook then has the
format '<hook>.<order>.<name>' (e.g., 'post-receive.10.send_mail'),
somewhat similar to /etc/rcX.d. It will also look in a .githooks.d
directory in the working directory (this can be disabled with a
config option). This is used by repository owners who want to add
extra hooks for their repositories, e.g., to add automatic code 
indentation before commit, or unit testing. It is also possible 
to specify more hook directories with a multi-value config option, 
which the user can use if he/she likes to add some personal hooks.
All hooks found in all drop directories are sorted by order before 
being executed so that it is possible to add local hooks before or
after the global ones.

This way it is possible to have system level hooks, repository
specific hooks and user specific hooks all work together. And even 
though I now have a system which works for us, having something like
this in the git core would be more efficient, and benefit more users.

Here is what my solution explained above would look like if it was 
added to the git core.

* The .git/hooks directory is replaced by .git/hooks.d (any hooks
  found in .git/hooks could be assumed to have an order of 50 for
  backwards compatibility).
* If core.repositoryHooks (better name?) is true (default to false) 
  then .githooks.d in the working directory is searched for hooks.
* It is possible to specify more hook directories using the 
  multi-value core.hookDirectory option (directories are relative to 
  the .git directory; absolute directories are of course also allowed).

//Peter


  reply	other threads:[~2010-07-05 10:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-02 16:23 global hooks - once again Eugene Sajine
2010-07-02 18:03 ` Jonathan Nieder
2010-07-02 19:30   ` Eugene Sajine
2010-07-02 19:18 ` Junio C Hamano
2010-07-02 19:47   ` Eugene Sajine
2010-07-05 10:03     ` Peter Kjellerstedt [this message]
2010-07-06 12:14       ` Alex Riesen
2010-07-06 12:23         ` Eugene Sajine
2010-07-06 14:55           ` Peter Kjellerstedt
2010-07-06 15:00             ` demerphq
2010-07-06 15:32               ` Eugene Sajine
2010-07-06 12:20       ` Eugene Sajine
2010-07-06 14:34     ` demerphq
2010-07-02 20:53   ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A612847CFE53224C91B23E3A5B48BAC744940F6E57@xmail3.se.axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=euguess@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).