Comparison

prosodyctl @ 6586:317ad7f1c2ba

prosodyctl: Use util.mercurial to identify hg repository and revision
author Kim Alvefur <zash@zash.se>
date Wed, 21 Jan 2015 02:55:23 +0100
parent 6584:c3a56f8847ac
child 6587:54306208f30b
comparison
equal deleted inserted replaced
6585:ec94dc502113 6586:317ad7f1c2ba
249 249
250 -- FIXME: Duplicate code waiting for util.startup 250 -- FIXME: Duplicate code waiting for util.startup
251 function read_version() 251 function read_version()
252 -- Try to determine version 252 -- Try to determine version
253 local version_file = io.open((CFG_SOURCEDIR or ".").."/prosody.version"); 253 local version_file = io.open((CFG_SOURCEDIR or ".").."/prosody.version");
254 prosody.version = "unknown";
254 if version_file then 255 if version_file then
255 prosody.version = version_file:read("*a"):gsub("%s*$", ""); 256 prosody.version = version_file:read("*a"):gsub("%s*$", "");
256 version_file:close(); 257 version_file:close();
257 if #prosody.version == 12 and prosody.version:match("^[a-f0-9]+$") then 258 if #prosody.version == 12 and prosody.version:match("^[a-f0-9]+$") then
258 prosody.version = "hg:"..prosody.version; 259 prosody.version = "hg:"..prosody.version;
259 end 260 end
260 else 261 else
261 prosody.version = "unknown"; 262 local hg = require"util.mercurial";
263 local hgid = hg.check_id(CFG_SOURCEDIR or ".");
264 if hgid then prosody.version = "hg:" .. hgid; end
262 end 265 end
263 end 266 end
264 267
265 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning; 268 local show_message, show_warning = prosodyctl.show_message, prosodyctl.show_warning;
266 local show_usage = prosodyctl.show_usage; 269 local show_usage = prosodyctl.show_usage;