Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto-generate a version string in git [duplicate]

Possible Duplicate:
Enable ident string for Git repos

In my project, every source file (regardless of the language - Java, Python, shell) has a comment line that contains source control information - branch, date of last commit, committer name, etc.

This is done by using special placeholders (e.g. $Branch$) which are auto-replaced by the source control application.

Is it possible to achieve similar functionality in git?

I am using Git Extensions on Windows and yet-to-be-decided GUI on Linux, but I assume both are just GUIs that invoke the git command-line tools.

like image 983
Amir K Avatar asked Jan 14 '23 07:01

Amir K


1 Answers

You have to read about smudge/clean filters in Git in order to get some iteration of keyword-replacement.

Grok section "Keyword Expansion", where example of expanding $DATE$ keyword explained (and a must reverse-operation). In you case most work of expanding $SOMEKEYWORD$ to version string can be performed by git describe under the hood, clean part must be implemented by hand (your hand)

like image 57
Lazy Badger Avatar answered Jan 16 '23 20:01

Lazy Badger