With RCS, I can create a perl file like:
#!/usr/bin/perl
my $version = '$Id: mycode,v 1.1 2019/01/26 13:54:27 jhnc Exp jhnc $';
print( join(" ", (split /[,\s]+/, $version)[1,3]), "\n");
Then, whenever I check the file in, the version will be updated. The aim is to avoid manual update of the version string.
I'm a git newbie. Is anything similar possible with git?
If I use a pre-commit hook I don't see how one gets the new git hash before the commit happens. And if I use post-commit, the change won't be committed. Is my only option to set up a parallel versioning scheme and use that in a pre-commit hook?