diff --git a/components/app/app.js b/components/app/app.js index acfdb1b04..5552325d0 100644 --- a/components/app/app.js +++ b/components/app/app.js @@ -67,10 +67,12 @@ class AppViewModel { this.latestVersion(version.latestVersion); this.showNewVersionAvailable(!ungit.config.ungitVersionCheckOverride && version.outdated); }).catch((e) => this.server.unhandledRejection(e)); - this.server.getPromise('/gitversion') - .then((gitversion) => { - if (gitversion && !gitversion.satisfied) { - this.gitVersionError(gitversion.error); + + const minGitVersion = '>=1.8.0' + this.server.getPromise('/gitversion', {requiredGitVersion: minGitVersion}) + .then((result) => { + if (result && !result.satisfied) { + this.gitVersionError(`Ungit requires git ${minGitVersion}, found ${result.type} ${result.version}`); } }).catch((e) => this.server.unhandledRejection(e)); } diff --git a/source/server.js b/source/server.js index 5553e4971..9a15dbeb2 100644 --- a/source/server.js +++ b/source/server.js @@ -301,7 +301,13 @@ app.get('/api/latestversion', (req, res) => { app.get('/api/ping', (req, res) => res.json({})); app.get('/api/gitversion', (req, res) => { - sysinfo.getGitVersionInfo().then((result) => res.json(result)); + sysinfo.getGitVersionInfo().then((result) => { + res.json({ + satisfied: semver.satisfies(result, req.query.requiredGitVersion), + version: result, + type: 'git' + }) + }); }); const userConfigPath = path.join(config.homedir, '.ungitrc'); diff --git a/source/sysinfo.js b/source/sysinfo.js index 6723c447c..fd63a1702 100644 --- a/source/sysinfo.js +++ b/source/sysinfo.js @@ -45,21 +45,5 @@ exports.getUserHash = () => { } exports.getGitVersionInfo = () => { - const result = { - requiredVersion: '>=1.8.x', - version: 'unkown', - satisfied: false - }; - - if (!config.gitVersion) { - result.error = `Failed to parse git version number. Note that Ungit requires git version ${result.requiredVersion}`; - } else { - result.version = config.gitVersion; - result.satisfied = semver.satisfies(result.version, result.requiredVersion); - if (!result.satisfied) { - result.error = `Ungit requires git version ${result.requiredVersion}, you are currently running ${result.version}`; - } - } - - return Bluebird.resolve(result); + return Bluebird.resolve(config.gitVersion); } diff --git a/test/spec.sysinfo.js b/test/spec.sysinfo.js new file mode 100644 index 000000000..b66fb6749 --- /dev/null +++ b/test/spec.sysinfo.js @@ -0,0 +1,8 @@ +const expect = require('expect.js'); +const sysinfo = require('../src/sysinfo'); + +describe('sysinfo', () => { + it('returns the gitversion', () => { + sysinfo.getGitVersionInfo().then((version) => expect(version).to.match(/\d+\.\d+\.\d+/)) + }); +});