-- >8 --
Subject: [PATCH] Makefile: git-based version number

>From e4f1f4c55fc89c76613e11cca8bad2cfafdd1ef2 Mon Sep 17 00:00:00 2001
From: David Favro <pros...@meta-dynamic.com>
Date: Mon, 28 Mar 2016 11:40:16 -0400
Subject: [PATCH] Makefile: git-based version number

In cases where someone is using a git front-end for VCS, will generate
a prosody-version file based on the git HEAD commit hash.  If that git
front-end repo is bridged from a hg backend repo, will also append the
latest hg commit hash.  Those not using git as their VCS front-end
will not be affected, nor those building a 'release' version.

Also notices if the local working tree has been modified from the
latest git commit and indicates accordingly.

A typical version number would then look like:
Or for a modified local source tree:

The old behavior was to call the version "unknown".

Signed-off-by: David Favro <pros...@meta-dynamic.com>
 Makefile       |  7 ++++---
 git-hg-version | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100755 git-hg-version

diff --git a/Makefile b/Makefile
index 06e67c9c..86bca44a 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,8 @@ prosody.cfg.lua.install: prosody.cfg.lua.dist
 %.version: .hg/dirstate
        hexdump -n6 -e'6/1 "%02x"' $^ > $@
-       echo unknown > $@
+%.version: .git/objects
+       ./git-hg-version > $@
+       echo "F" unknown > $@
diff --git a/git-hg-version b/git-hg-version
new file mode 100755
index 00000000..dcb2b2c6
--- /dev/null
+++ b/git-hg-version
@@ -0,0 +1,20 @@
+# Simple script to try to generate a version-number for people
+# installing from a git front-end.
+# Deliberately don't consider new untracked files to be a dirty tree
+# (when all untracked files are clean), because this is too likely to
+# be inconsequential files that won't be installed.
+dirty="`git status -uno --short | egrep -q '^ *M' && echo local:dirty/`"
+gitv="git:`git -c core.abbrev=8 rev-parse --short HEAD`"
+# Hg-backend-to-git-frontend typically keeps a .hg repo inside .git:
+if test -d .git/hg/.hg
+       then
+       # Get the latest commit hash from hg.
+       hgv="/hg:`hg -R .git/hg log --limit 1 | head -1 | sed 's/^.*://'`"
+       fi
+echo "${dirty}${gitv}${hgv}"

You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To post to this group, send email to prosody-dev@googlegroups.com.
Visit this group at https://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to