From e7c9f8d9c7a0e3a0fb06661682a9318eebcbb12b Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Wed, 27 Aug 2014 11:51:50 -0300 Subject: [PATCH 1/3] Added commit Hash to home page --- copay.js | 3 ++- js/controllers/version.js | 1 + util/build.js | 14 +++++++++++++- views/includes/version.html | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/copay.js b/copay.js index 35178e9a3..5f058d6ab 100644 --- a/copay.js +++ b/copay.js @@ -16,7 +16,8 @@ var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('./js module.exports.WalletFactory = require('./js/models/core/WalletFactory'); module.exports.Wallet = require('./js/models/core/Wallet'); module.exports.WalletLock = require('./js/models/core/WalletLock'); -module.exports.version = require('./version'); +module.exports.version = require('./version').version; +module.exports.commitHash = require('./version').commitHash; // test hack :s, will fix module.exports.FakePayProServer = require('./test/mocks/FakePayProServer'); diff --git a/js/controllers/version.js b/js/controllers/version.js index 5e886c44a..f00fcc13a 100644 --- a/js/controllers/version.js +++ b/js/controllers/version.js @@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('VersionController', function($scope, $rootScope, $http, notification) { $scope.version = copay.version; + $scope.commitHash = copay.commitHash; $scope.networkName = config.networkName; $http.get('https://api.github.com/repos/bitpay/copay/tags').success(function(data) { diff --git a/util/build.js b/util/build.js index db14b847d..3382fbb3f 100644 --- a/util/build.js +++ b/util/build.js @@ -5,13 +5,25 @@ var fs = require('fs'); var browserify = require('browserify'); var exec = require('child_process').exec; +var shell = require('shelljs'); + var puts = function(error, stdout, stderr) { if (error) console.log(error); }; +var getCommitHash = function() { + //exec git command to get the hash of the current commit + //git rev-parse HEAD + + var hash = shell.exec('git rev-parse HEAD').output.trim().substr(0,10); + return hash; +} + var createVersion = function() { var json = JSON.parse(fs.readFileSync('./package.json', 'utf8')); - var content = 'module.exports="' + json.version + '";'; + var content = 'module.exports.version="' + json.version + '";'; + + content = content + '\nmodule.exports.commitHash="' + getCommitHash() + '";'; fs.writeFileSync("./version.js", content); }; diff --git a/views/includes/version.html b/views/includes/version.html index 664152ca4..f3a19d227 100644 --- a/views/includes/version.html +++ b/views/includes/version.html @@ -1,5 +1,6 @@
v{{version}} [ {{networkName}} ] + {{commitHash}}
From acde51cf87a5b48cca8c6c82eaa46074fb990b4c Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Wed, 27 Aug 2014 15:09:45 -0300 Subject: [PATCH 2/3] Added shelljs dependency --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 55572279e..745f3ac48 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,8 @@ "socket.io-client": "1.0.6", "travis-cov": "0.2.5", "uglifyify": "1.2.3", - "crypto-js": "3.1.2" + "crypto-js": "3.1.2", + "shelljs":"0.3.0" }, "main": "app.js", "homepage": "https://github.com/bitpay/copay", From 20c78ce130121b8064b93d7469e9d57533d8e1a2 Mon Sep 17 00:00:00 2001 From: Matias Pando Date: Thu, 28 Aug 2014 10:00:18 -0300 Subject: [PATCH 3/3] Minor cosmetic fixes --- util/build.js | 2 +- views/includes/version.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/build.js b/util/build.js index 3382fbb3f..2ea62d84c 100644 --- a/util/build.js +++ b/util/build.js @@ -15,7 +15,7 @@ var getCommitHash = function() { //exec git command to get the hash of the current commit //git rev-parse HEAD - var hash = shell.exec('git rev-parse HEAD').output.trim().substr(0,10); + var hash = shell.exec('git rev-parse HEAD',{silent:true}).output.trim().substr(0,7); return hash; } diff --git a/views/includes/version.html b/views/includes/version.html index f3a19d227..8ad2c64c5 100644 --- a/views/includes/version.html +++ b/views/includes/version.html @@ -1,6 +1,6 @@
v{{version}} + #{{commitHash}} [ {{networkName}} ] - {{commitHash}}