summary refs log tree commit diff
path: root/gen-version.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-12-27 18:45:04 -0500
committerJune McEnroe <june@causal.agency>2020-12-27 18:45:04 -0500
commit85016e706cd00e527dba3fa83b2783dfb56a4ffa (patch)
treefc28a97fede3b74ae2cb2e778ffd4c0ae59c637b /gen-version.sh
downloadsrc-85016e706cd00e527dba3fa83b2783dfb56a4ffa.tar.gz
src-85016e706cd00e527dba3fa83b2783dfb56a4ffa.zip
Squashed 'www/git.causal.agency/cgit/' content from commit 02221fd3
git-subtree-dir: www/git.causal.agency/cgit
git-subtree-split: 02221fd3fe523a3293d64e3359036e3a71d6fd7e
Diffstat (limited to '')
-rwxr-xr-xgen-version.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/gen-version.sh b/gen-version.sh
new file mode 100755
index 00000000..80cf49af
--- /dev/null
+++ b/gen-version.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Get version-info specified in Makefile
+V=$1
+
+# Use `git describe` to get current version if we're inside a git repo
+if test "$(git rev-parse --git-dir 2>/dev/null)" = '.git'
+then
+	V=$(git describe --abbrev=4 HEAD 2>/dev/null)
+fi
+
+new="CGIT_VERSION = $V"
+old=$(cat VERSION 2>/dev/null)
+
+# Exit if VERSION is uptodate
+test "$old" = "$new" && exit 0
+
+# Update VERSION with new version-info
+echo "$new" > VERSION
+cat VERSION