{"thread":{"id":"18925","subject":"[PATCH] Add a post-tag hook","startedAt":"2009-04-17T22:15:46Z","lastAt":"2009-04-24T16:41:47Z","messageCount":4,"participants":["Ammon Riley","Shawn O. Pearce","Pat Notz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"111540","messageId":"cd3664ac0904171515u1e2fce41ubd34f60ec43fcafd@mail.gmail.com","threadId":"18925","inReplyTo":null,"subject":"[PATCH] Add a post-tag hook","fromName":"Ammon Riley","fromEmail":"ammon.riley@gmail.com","sentAt":"2009-04-17T22:15:46Z","receivedAt":"2009-04-17T22:15:46Z","isPatch":true,"sender":{"key":"ammon.riley@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1801261?v=4"},"body":"Add a post-tag hook, to allow notifications when a tag is created.\nThe hook is given the name of the newly created tag.\n\nSigned-off-by: Ammon Riley <ammon.riley@gmail.com>\n---\n Documentation/git-tag.txt        |    4 ++++\n Documentation/githooks.txt       |    9 +++++++++\n builtin-tag.c                    |    2 ++\n t/t3800-tag-hook.sh              |   32 ++++++++++++++++++++++++++++++++\n templates/hooks--post-tag.sample |    8 ++++++++\n 5 files changed, 55 insertions(+), 0 deletions(-)\n create mode 100755 t/t3800-tag-hook.sh\n create mode 100755 templates/hooks--post-tag.sample\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex fa73321..3fcb3d4 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -248,6 +248,10 @@ An example follows.\n $ GIT_COMMITTER_DATE=\"2006-10-02 10:31\" git tag -s v1.0.1\n ------------\n\n+HOOKS\n+-----\n+This command can run the `post-tag` hook. See linkgit:githooks[5]\n+for more information.\n\n Author\n ------\ndiff --git a/Documentation/githooks.txt b/Documentation/githooks.txt\nindex 1c73673..4512f18 100644\n--- a/Documentation/githooks.txt\n+++ b/Documentation/githooks.txt\n@@ -314,6 +314,15 @@ This hook is invoked by 'git-gc --auto'. It takes\nno parameter, and\n exiting with non-zero status from this script causes the 'git-gc --auto'\n to abort.\n\n+post-tag\n+--------\n+\n+This hook is invoked by 'git-tag'.  It takes one parameter, the name\n+of the tag, and is invoked after a tag is made.\n+\n+This hook is meant primarily for notification, and cannot affect\n+the outcome of 'git-tag'.\n+\n GIT\n ---\n Part of the linkgit:git[1] suite\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex 01e7374..e4509ba 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -482,6 +482,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tif (write_ref_sha1(lock, object, NULL) < 0)\n \t\tdie(\"%s: cannot update the ref\", ref);\n\n+\trun_hook(NULL, \"post-tag\", tag, NULL);\n+\n \tstrbuf_release(&buf);\n \treturn 0;\n }\ndiff --git a/t/t3800-tag-hook.sh b/t/t3800-tag-hook.sh\nnew file mode 100755\nindex 0000000..68c5877\n--- /dev/null\n+++ b/t/t3800-tag-hook.sh\n@@ -0,0 +1,32 @@\n+#!/bin/sh\n+\n+test_description='git tag with its hook\n+\n+This test creates a post-tag hook and tests it.'\n+\n+. ./test-lib.sh\n+\n+TAG_FILE=\"$(pwd)/output\"\n+export TAG_FILE\n+\n+test_expect_success 'Setting up post-tag hook' '\n+    mkdir -p .git/hooks &&\n+    echo >.git/hooks/post-tag \"#!/bin/sh\n+    echo -n \\$@ > \\\"\\${TAG_FILE}\\\"\n+    echo Post commit hook was called.\" &&\n+    chmod +x .git/hooks/post-tag\n+'\n+\n+test_expect_success 'post-tag hook gets correct input' '\n+    test \\! -e \"${TAG_FILE}\" &&\n+    echo initial >file &&\n+    git add file &&\n+    git commit -m initial &&\n+    git tag mytag &&\n+    test -r \"${TAG_FILE}\" &&\n+    test \"z$(cat \"${TAG_FILE}\")\" = zmytag\n+'\n+\n+rm -rf \"${TAG_FILE}\"\n+\n+test_done\ndiff --git a/templates/hooks--post-tag.sample b/templates/hooks--post-tag.sample\nnew file mode 100755\nindex 0000000..5f6a3d3\n--- /dev/null\n+++ b/templates/hooks--post-tag.sample\n@@ -0,0 +1,8 @@\n+#!/bin/sh\n+#\n+# An example hook script that is called after a successful\n+# tag is made.\n+#\n+# To enable this hook, rename this file to \"post-tag\".\n+\n+: Nothing\n-- \n1.5.4.3\n"},{"id":"111546","messageId":"20090417221944.GS23604@spearce.org","threadId":"18925","inReplyTo":"cd3664ac0904171515u1e2fce41ubd34f60ec43fcafd@mail.gmail.com","subject":"Re: [PATCH] Add a post-tag hook","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-04-17T22:19:44Z","receivedAt":"2009-04-17T22:19:44Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Ammon Riley <ammon.riley@gmail.com> wrote:\n> Add a post-tag hook, to allow notifications when a tag is created.\n> The hook is given the name of the newly created tag.\n\nWhy would you want to send notifications upon creating a tag in\nyour local repository?\n\nUsually a tag is only interesting when it has been sent to a shared\npublic repository, which is by git push, and thus is caught by a\ngit receive-pack hook like post-update or post-receive.\n\n> +HOOKS\n> +-----\n> +This command can run the `post-tag` hook. See linkgit:githooks[5]\n> +for more information.\n...\n> +post-tag\n> +--------\n> +\n> +This hook is invoked by 'git-tag'.  It takes one parameter, the name\n> +of the tag, and is invoked after a tag is made.\n> +\n> +This hook is meant primarily for notification, and cannot affect\n> +the outcome of 'git-tag'.\n\n-- \nShawn.\n"},{"id":"111547","messageId":"cd3664ac0904171528p3ed55071p4e098f5181fb0b27@mail.gmail.com","threadId":"18925","inReplyTo":"20090417221944.GS23604@spearce.org","subject":"Re: [PATCH] Add a post-tag hook","fromName":"Ammon Riley","fromEmail":"ammon.riley@gmail.com","sentAt":"2009-04-17T22:28:04Z","receivedAt":"2009-04-17T22:28:04Z","isPatch":true,"sender":{"key":"ammon.riley@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1801261?v=4"},"body":"On Fri, Apr 17, 2009 at 3:19 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Ammon Riley <ammon.riley@gmail.com> wrote:\n>> Add a post-tag hook, to allow notifications when a tag is created.\n>> The hook is given the name of the newly created tag.\n>\n> Why would you want to send notifications upon creating a tag in\n> your local repository?\n>\n> Usually a tag is only interesting when it has been sent to a shared\n> public repository, which is by git push, and thus is caught by a\n> git receive-pack hook like post-update or post-receive.\n\nOn the particular project I'm working on, we're not really using git\nin the most distributed fashion -- it's completely internal to the\ncompany. In our case, the tags are being created directly on\nthe shared repository, rather than on a local repository and being\npushed.\n\nCheers,\nAmmon\n"},{"id":"112217","messageId":"1cd1989b0904240941o3d80bdbby19fb02093c887af@mail.gmail.com","threadId":"18925","inReplyTo":"cd3664ac0904171528p3ed55071p4e098f5181fb0b27@mail.gmail.com","subject":"Re: [PATCH] Add a post-tag hook","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2009-04-24T16:41:47Z","receivedAt":"2009-04-24T16:41:47Z","isPatch":true,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"On Fri, Apr 17, 2009 at 4:28 PM, Ammon Riley <ammon.riley@gmail.com> wrote:\n>\n> On Fri, Apr 17, 2009 at 3:19 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > Ammon Riley <ammon.riley@gmail.com> wrote:\n> >> Add a post-tag hook, to allow notifications when a tag is created.\n> >> The hook is given the name of the newly created tag.\n> >\n> > Why would you want to send notifications upon creating a tag in\n> > your local repository?\n> >\n> > Usually a tag is only interesting when it has been sent to a shared\n> > public repository, which is by git push, and thus is caught by a\n> > git receive-pack hook like post-update or post-receive.\n>\n> On the particular project I'm working on, we're not really using git\n> in the most distributed fashion -- it's completely internal to the\n> company. In our case, the tags are being created directly on\n> the shared repository, rather than on a local repository and being\n> pushed.\n\nToday, this same situation came up in my organization.  It seem like a\nnatural partner of the post-commit hook.\n\n>\n> Cheers,\n> Ammon\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}