0

Is there an option that would allow me to place a variable place holder to a git environment variable and upon committing, have that variable be populated with the information within it?

I have an XML file that I have appended my changes too, while providing a comment for visual satisfaction for those who dont use Git and review my files. I want to append the date of the commit from GIT into that variable place holder in the document.

<root>
    <!--CR **{git_commit_date}**: Added a root.-->
</root>
Krptodr
  • 139
  • 13
  • 1
    I don't *think* git offers that sort of option, but I could be wrong. Your use case sounds like a changelog tho, and there does exist good automation for that. https://stackoverflow.com/questions/3523534/good-ways-to-manage-a-changelog-using-git#22492425 – Jacob Vanus Mar 21 '18 at 16:36

1 Answers1

1

Yes and no.

What you are after is traditionally (since SCCS or may be even older) is called "keyword expansion" — as it was used to expand special placeholders such as $Id$ by some meta-information from the most recent commit created by a VCS.

Git explicitly refuses to support this out of the box but provides means to do that with the help of external tools.

Here is a gentle introduction to the topic, and here is the manual.

kostix
  • 51,517
  • 14
  • 93
  • 176