]> git.refcnt.org Git - colorize.git/blobdiff - version.pl
Include commit hash in version output
[colorize.git] / version.pl
diff --git a/version.pl b/version.pl
new file mode 100755 (executable)
index 0000000..850902e
--- /dev/null
@@ -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
+}