Skip to content

Node.js based forum software built for the modern web

display git hash/branch

barisusakli8d0cb18b74aa
diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js
index a9a489f6c4..5ea0441809 100644
--- a/src/controllers/admin/info.js
+++ b/src/controllers/admin/info.js
@@ -1,6 +1,8 @@
'use strict';
+var async = require('async');
var os = require('os');
+var exec = require('child_process').exec;
var infoController = {};
@@ -18,12 +20,36 @@ infoController.get = function(req, res, next) {
uptime: process.uptime()
},
os: {
- hostname: os.hostname()
+ hostname: os.hostname(),
+ type: os.type(),
+ platform: os.platform(),
+ arch: os.arch(),
+ release: os.release()
}
};
-
- res.render('admin/development/info', {info: JSON.stringify(data, null, 4)});
+ getGitInfo(function(err, gitInfo) {
+ if (err) {
+ return next(err);
+ }
+ data.git = gitInfo;
+ res.render('admin/development/info', {info: JSON.stringify(data, null, 4)});
+ });
};
+function getGitInfo(callback) {
+ function get(cmd, callback) {
+ exec(cmd, function(err, stdout) {
+ callback(err, stdout ? stdout.replace(/\n$/, '') : '');
+ });
+ }
+ async.parallel({
+ hash: function(next) {
+ get('git rev-parse HEAD', next);
+ },
+ branch: function(next) {
+ get('git rev-parse --abbrev-ref HEAD', next);
+ }
+ }, callback);
+}
module.exports = infoController;
\ No newline at end of file