Having read some postings here about this topic, I realize that there are quite some cons that speak against using keyword-substitution. Nevertheless, I need a way to solve following problem and hope that somebody might have an idea on how to solve this with git (whether or not with keyword-substitution):
I have a main application for which I use git as VCS. Parts of this main application (a certain set of XML-Files) are being used by a utility for which I also use git (separate repo).
Now, the main app and the utility have different release cycles, and whenever I release a new version of the utility, I copy over the most current set of XML-Files from the main application. Within the utility, this set of XML-Files is non-versioned content in git, so it's not even checked in to the repo.
As of now, whenever I look at different releases of this utility (which is managed by git and has tagged releases) I have no way of knowing which "version" (better: commit hash) the set of contained XML-Files is referring to.
So I was thinking: if I can have the latest commit SHA within those XML-Files (as a comment), I'd always know to which set of XML-Files a certain version of my utility refers to. Is there anything wrong in this approach or is this the way to go? If yes, how do I get the latest commit-SHA into my XML-Files? (I read that $Id:$ won't take the commit-SHA, but some "blob"-SHA?)
Ok guys, based on your input, this is what i did:
<!-- @GIT_VERSION@ -->
Code:
Thanks for your help!
See also:
How to lookup the latest git commit hash from an ant build script
Deriving application build version from `git describe` - how to get a relatively straightforward string?