git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git tag: pre-receive hook issue

From
Jacob Keller <jacob.keller@gmail.com>
Date
Jul 18, 2015, 04:00 UTC
Message-ID
<CA+P7+xoXgSHPVhMTm_GZbq+6Pps5yttK2rBZpMycTUFGfqOCvw@mail.gmail.com>
In-Reply-To
<1437159533304-7635764.post@n2.nabble.com>
On Fri, Jul 17, 2015 at 11:58 AM, Garbageyard <varuag.chhabra@gmail.com> wrote:
Show 15 quoted lines
> We have a pre-receive hook that checks for JIRA ID whenever someone pushes
> code to Git server. I'm trying to avoid this check when someone is applying
> a tag. Here's the link for the script: http://pastebin.com/VnMQp5ar
>
> This is the link for output: http://pastebin.com/tBGmYaZF
>
> Problem is that if i run the following command, the output that i get on
> command line is 0
>
> git describe --exact-match ac28ca721e67adc04078786164939989a5112d98 2>&1 |
> grep -o fatal | wc -w
>
> So i'm wondering why it's not entering the IF block (as confirmed in the
> output link)
>

Probably due to environment variables set by the git hook. But.. this is definitely not at *ALL* what you want to do. Junio has a good explanation below. This doesn't make even any sense at all to me...

Show 7 quoted lines
> I agree this is a bad implementation (and i will change it soon) for
> checking tags and can be easily done by just checking whether $refname
> starts with refs/tags/ but i'll really appreciate if someone could tell me
> the mistake i'm committing. I've spent few hours banging my head on this.
>
>
>
Ok, so the issue I believe is this:

you're running git describe on the local side. But the pre-receive hook hasn't actually accepted the ref yet so git-describe on the server will fail.

This is why you should just check refs/tags/* as regular pre-receive hook examples do.

Regards, Jake

Show 7 quoted lines
> --
> View this message in context: http://git.661346.n2.nabble.com/Git-tag-pre-receive-hook-issue-tp7635764.html
> Sent from the git mailing list archive at Nabble.com.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Junio C HamanoNext: Gaurav Chhabra
Message 3 of 13 in “Git tag: pre-receive hook issue”
  1. GarbageyardJul 17, 2015
  2. Junio C HamanoJul 17, 2015
  3. Jacob KellerJul 18, 2015
  4. Gaurav ChhabraJul 18, 2015
  5. Junio C HamanoJul 18, 2015
  6. Jacob KellerJul 18, 2015
  7. Gaurav ChhabraJul 19, 2015
  8. Jacob KellerJul 19, 2015
  9. Gaurav ChhabraJul 19, 2015
  10. Jacob KellerJul 19, 2015
  11. Gaurav ChhabraJul 20, 2015
  12. Keller, Jacob EJul 20, 2015
  13. Jakub NarębskiJul 22, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.