Can you get the next commit id before items are co

2019-09-16 04:03发布

问题:

I'm currently adding a commit-msg hook that will add the git commit URL as a comment to Jira. The commit URL has the format

http://[server]/[group]/[project]/commit/[commit_id]

Is it possible to obtain the commit id or is it only produced after the item has been committed? Does this mean I need to implement this in a later hook?

回答1:

A git commit id is a SHA-1 hash of:

  • The commit message
  • Author and committer info
  • The date
  • The contents (the hash of the tree)
  • The parent commit hash (or hashes, for merges)

So, the commit id can only be produced after the item has been committed.