diff options
author | Steven Schubiger <stsc@refcnt.org> | 2014-06-26 16:08:37 +0200 |
---|---|---|
committer | Steven Schubiger <stsc@refcnt.org> | 2014-06-26 16:08:37 +0200 |
commit | 5f02f11890b79f3254fbafa67ee6600982953856 (patch) | |
tree | a1948041408bdbbc4ab2067a6a15b6936061ea61 /version.pl | |
parent | 055b7ca1312376f2fdf214176a1ae782d05f5396 (diff) | |
download | colorize-5f02f11890b79f3254fbafa67ee6600982953856.tar.gz colorize-5f02f11890b79f3254fbafa67ee6600982953856.tar.bz2 |
Include commit hash in version output
Extracting the abbreviated commit hash will break when git will be
replaced by a different version control system. But until it does,
get the hash from the git repository.
Diffstat (limited to 'version.pl')
-rwxr-xr-x | version.pl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/version.pl b/version.pl new file mode 100755 index 0000000..850902e --- /dev/null +++ b/version.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my $version = ''; + +# git repository +if (system('which git >/dev/null 2>&1') == 0 +and system('git ls-files colorize.c --error-unmatch >/dev/null 2>&1') == 0) { + $version = `git describe --tags --dirty`; + $version =~ s/\n$//g; +} + +if (length $version) { + print <<"EOT"; +const char *version = "$version"; +EOT +} +else { + print <<'EOT'; +const char *version = NULL; +EOT +} |