From: Junio C Hamano <gitster@pobox.com>
To: Aske Olsson <askeolsson@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add support for a 'pre-push' hook
Date: Fri, 16 Nov 2012 12:30:19 -0800 [thread overview]
Message-ID: <7vvcd5l290.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CAJwKrPYwCE4ExmK09PURMfjYezn6vdCH_BBXU4WCwrnotyV9CA@mail.gmail.com> (Aske Olsson's message of "Fri, 16 Nov 2012 20:42:59 +0100")
Aske Olsson <askeolsson@gmail.com> writes:
> If the script .git/hooks/pre-push exists and is executable it will be
> called before a `git push` command, and when the script exits with a
> non-zero status the push will be aborted.
> The hook can be overridden by passing the '--no-verify' option to
> `git push`.
>
> The pre-push hook is usefull to run tests etc. before push. Or to make
> sure that if a binary solution like git-media, git-annex or git-bin is
> used the binaries are uploaded before the push, so when others do a
> fetch the binaries will be available already. This also reduces the
> need for introducing extra (git) commands to e.g. sync binaries.
>
> Signed-off-by: Aske Olsson <askeolsson@gmail.com>
> ---
> ...
> +[[pre-push]]
> +pre-push
> +~~~~~~~~
> +
> +This hook is invoked by 'git push' and can be bypassed with the
> +`--no-verify` option. It takes no parameter, and is invoked before
> +the push happens.
> +Exiting with a non-zero status from this script causes 'git push'
> +to abort.
> ...
> + if (!no_verify && run_hook(NULL, "pre-push")) {
> + die(_("pre-push hook failed: exiting\n"));
> + }
NAK, at least in the current form. At least the system should tell
the hook where it is pushing and what is being pushed.
After working on my notebook, I may want to push to my desktop
machine first to test it, without having to test locally on an
underpowered CPU, but when I am publishing the end result to the
wider world, I do want to test the result beforehand. Without
"where am I pushing", the hook would not help me to enforce testing
only for the latter.
A lazy "git push" without any other argument may be configured in my
repository to push its "maint", "master", "next" and "pu" branches
to the public repository. I may say "git push origin +pu", while on
one of the topic branches, to push only the "pu" branches out before
I am confident that the other branches I'll eventually publish are
ready (it is more likely that I may even *know* they are broken and
do not pass the test in such a case, and that is why I am pushing
only "pu" out). I'd want to run tests only on 'pu' in such a case.
Without "what am I pushing", the hook would not be able to help me
doing that, either.
Besides, there are five valid reasons to add a new hook to the
system, but your version of pre-push does not satisfy any of them:
http://thread.gmane.org/gmane.comp.version-control.git/94111/focus=71069
It is more like "to always cause an action before running a git
operation locally," so you can even write
cat >$HOME/bin/git-mypush <<\EOF
#!/bin/sh
run test || exit
exec git push "$@"
EOF
chmod +x $HOME/bin/git-mypush
and then can run "git mypush" instead of adding this hook.
next prev parent reply other threads:[~2012-11-16 20:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-16 19:42 [PATCH] Add support for a 'pre-push' hook Aske Olsson
2012-11-16 20:25 ` Matthieu Moy
2012-11-16 21:23 ` Junio C Hamano
2012-11-17 9:00 ` Aske Olsson
2012-11-16 20:30 ` Junio C Hamano [this message]
2012-11-17 6:39 ` Michael Haggerty
2012-11-17 8:47 ` Aske Olsson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vvcd5l290.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=askeolsson@gmail.com \
--cc=git@vger.kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox