From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Neal Kreitzinger <nkreitzinger@gmail.com>,
Adrian Cornish <git@bluedreamer.com>
Subject: [PATCH 1/(3/4)] test: does pre-commit-hook learn authorship?
Date: Sun, 11 Mar 2012 04:08:20 -0700 [thread overview]
Message-ID: <7v1uozz97f.fsf_-_@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7v62ebz9c0.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Sun, 11 Mar 2012 04:05:35 -0700")
When "--author" option is used to lie the authorship to "git commit"
command, hooks should learn the author name and email just like when
GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables are used
to lie the authorship. Test this.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* This is the first one of two patches that are shread by two
approaches. What it tests should be obvious---the current code
fails with the last piece that use --author.
t/t7503-pre-commit-hook.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh
index ee7f0cd..fc6de5b 100755
--- a/t/t7503-pre-commit-hook.sh
+++ b/t/t7503-pre-commit-hook.sh
@@ -118,4 +118,22 @@ test_expect_success 'with failing hook requiring GIT_PREFIX' '
git checkout -- file
'
+test_expect_failure 'check the author in hook' '
+ cat >"$HOOK" <<-\EOF &&
+ test "$GIT_AUTHOR_NAME" = "New Author" &&
+ test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com"
+ EOF
+ test_must_fail git commit --allow-empty -m "by a.u.thor" &&
+ (
+ GIT_AUTHOR_NAME="New Author" &&
+ GIT_AUTHOR_EMAIL="newauthor@example.com" &&
+ export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
+ git commit --allow-empty -m "by new.author via env" &&
+ git show -s
+ ) &&
+ git commit --author="New Author <newauthor@example.com>" \
+ --allow-empty -m "by new.author via command line" &&
+ git show -s
+'
+
test_done
--
1.7.10.rc0.33.g8866af
next prev parent reply other threads:[~2012-03-11 11:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-09 1:15 Stop a git commit by a specific author using pre-commit hook Adrian Cornish
2012-03-10 19:41 ` Neal Kreitzinger
2012-03-10 21:54 ` Junio C Hamano
2012-03-10 23:03 ` Neal Kreitzinger
2012-03-11 11:05 ` Junio C Hamano
2012-03-11 11:08 ` Junio C Hamano [this message]
2012-03-11 20:30 ` [PATCH 1/(3/4)] test: does pre-commit-hook learn authorship? Johannes Sixt
2012-03-11 21:09 ` Junio C Hamano
2012-03-11 11:09 ` [PATCH 2/(3/4)] ident.c: add split_ident_line() to parse formatted ident line Junio C Hamano
2012-03-11 11:11 ` [PATCH 3/3] commit: pass author/committer info to hooks Junio C Hamano
2012-03-12 11:29 ` Jeff King
2012-03-11 11:15 ` [PATCH 3/4] run_hook(): enhance the interface to pass arbitrary environment Junio C Hamano
2012-03-11 11:16 ` [PATCH 4/4] commit: pass author/committer info to hooks Junio C Hamano
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=7v1uozz97f.fsf_-_@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@bluedreamer.com \
--cc=git@vger.kernel.org \
--cc=nkreitzinger@gmail.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.
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 NNTP newsgroup(s).