0

Is it possible to inject the git commit reivision in the comments , means The git commit id .. e.g in the file comments we will have git revision : $gitrevision when you merge $gitrevision , It should get replaced by the actual commit id from git .

Is there any way for that , any help is appreciated ..

devbranch
  • 23
  • 1
  • 7

1 Answers1

4

I think it is not possible because the commit id or hash is made of a few things and one of them is the commit message.

Here's a nice answer from another question on StackOverflow, where it states all the things used to make a commit hash, which are:

Git uses the following information to generate the sha-1:

  • The source tree of the commit (which unravels to all the subtrees and blobs)
  • The parent commit sha1
  • The author info (with timestamp)
  • The committer info (right, those are different!, also with timestamp)
  • The commit message

The last one being what you're trying to use after the hash is generated.

Bernardo Duarte
  • 4,074
  • 4
  • 19
  • 34
  • Yes. To check it by yourself, just use `git cat-file -p ` on any commit and you'll see exactly **what** constitutes the commit (the info listed in the answer here). – Romain Valeri Jun 05 '21 at 07:48