0

Is there a way to include the branch/commit id in the source, so it changes automatically?

in rcs there is the $Id:$ tags, which gets expanded, and can be used as text strings:

$VERS = '$Id: prog.php,v 1.8 2016/01/07 14:14:48 root Exp root $';

and the Log:

/*
* $Log: pos.php,v $
* Revision 1.8  2016/01/07 14:14:48  root
* Beep for opening drawer
*
* Revision 1.2.1.1  2011/12/23 09:06:16  root
* Log
*
*/

I'd like the enduser to be able to see the version/build etc info.

Leif Neland
  • 1,416
  • 1
  • 17
  • 40

2 Answers2

0

There is no such way in git, the existing $Id in git will give you only the version of the current file not the whole repository.

And there is no equivalent of $Log$ either.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
0

If it is not possible, as krzyk say, then I'll make a script to

git log -1 | formatLogPhp.awk > untracked_file.txt

untracked_file.txt could be

<?php
$_GIT_commit="76a80d0308f1fca6685cf87f9c210d6d67ba6171";
$_GIT_Author="Leif Neland <leif@my.dom>";
$_GIT_date=  "Fri Jun 24 13:13:24 2016 +0200";
$_GIT_log = "Initial checkin";
?>

then

<?php
require_once("untracked_file.txt");

...
echo "Welcome to mygloriousProgram version ".$_GIT_date";
Leif Neland
  • 1,416
  • 1
  • 17
  • 40