prosodyctl: Use util.mercurial to identify hg repository and revision
authorKim Alvefur <zash@zash.se>
Wed, 21 Jan 2015 01:55:23 +0000 (02:55 +0100)
committerKim Alvefur <zash@zash.se>
Wed, 21 Jan 2015 01:55:23 +0000 (02:55 +0100)
prosodyctl

index 60bc0c08629b8b1ea2e8d3cd48564ca6e5e87f56..c7daceac579184a4c3192f6e38ff7f54549d9d17 100755 (executable)
@@ -251,6 +251,7 @@ require "socket"
 function read_version()
        -- Try to determine version
        local version_file = io.open((CFG_SOURCEDIR or ".").."/prosody.version");
+       prosody.version = "unknown";
        if version_file then
                prosody.version = version_file:read("*a"):gsub("%s*$", "");
                version_file:close();
@@ -258,7 +259,9 @@ function read_version()
                        prosody.version = "hg:"..prosody.version;
                end
        else
-               prosody.version = "unknown";
+               local hg = require"util.mercurial";
+               local hgid = hg.check_id(CFG_SOURCEDIR or ".");
+               if hgid then prosody.version = "hg:" .. hgid; end
        end
 end