summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtools/mkgit.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/mkgit.rb b/tools/mkgit.rb
new file mode 100755
index 0000000..2a6ef4c
--- /dev/null
+++ b/tools/mkgit.rb
@@ -0,0 +1,28 @@
1#!/usr/bin/ruby -w
2
3$stdout.write(<<END)
4#include "git-tag.h"
5
6END
7
8IO.popen(["git", "describe", "--always", "--dirty", "--long", "--tags"], "r") do | io |
9 $stdout.write("const char *GIT_TAG = #{io.read.strip.dump};\n")
10end
11
12IO.popen(["git", "diff"]) do | io |
13 diff = io.read
14 if diff.strip == ""
15 $stdout.write("const char *GIT_DIFF = nullptr;\n")
16 else
17 $stdout.write("const char *GIT_DIFF = #{diff.dump};\n")
18 end
19end
20
21IO.popen(["git", "diff", "--stat"]) do | io |
22 stat = io.read
23 if stat.strip == ""
24 $stdout.write("const char *GIT_STAT = nullptr;\n")
25 else
26 $stdout.write("const char *GIT_STAT = #{stat.dump};\n")
27 end
28end