From c63c34ad8811743a792bda599f252c174dafad84 Mon Sep 17 00:00:00 2001 From: Imran Ismail Date: Fri, 8 Jan 2016 18:48:05 +0800 Subject: [PATCH 1/3] push tag --- index.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 1ff522b..2fbffce 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,8 @@ module.exports = { var revisionKey = this.readConfig("revisionKey"); var deployTarget = context.deployTarget; return ["deploy", deployTarget, revisionKey].join('-'); - } + }, + deployBranch: "master" }, configure: function(/*context*/) { @@ -27,20 +28,31 @@ module.exports = { }, didDeploy: function(context) { - var tag = this.readConfig("deployTag"); - var repo = (context._Git || gitty)("."); - var _this = this; + var tag = this.readConfig("deployTag"); + var branch = this.readConfig("deployBranch") + var repo = (context._Git || gitty)("."); + var _this = this; return new Promise(function(resolve, reject) { repo.createTag(tag, function(e) { if (e) { - _this.log(e, { color: 'red' }); reject(e); + } else { + resolve(repo, tag); + } + }); + }).then(function(repo, tag) { + repo.push("origin", branch, ["--tags", tag], function(error, success) { + if (error) { + _this.log(error, { color: 'red' }); + return Promise.reject(error) } else { _this.log("tagged "+tag, { verbose: true }); - resolve(); + return Promise.resolve() } }); + }, function(error) { + _this.log(e, { color: 'red' }); }); } }); From b1d5c9e211baaad685b429e75ec044039c938bca Mon Sep 17 00:00:00 2001 From: Imran Ismail Date: Fri, 8 Jan 2016 18:48:15 +0800 Subject: [PATCH 2/3] add test --- tests/unit/index-nodetest.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js index 5eb4e54..578fcab 100644 --- a/tests/unit/index-nodetest.js +++ b/tests/unit/index-nodetest.js @@ -12,9 +12,11 @@ var stubProject = { }; var mockCreateTag = function(tag, cb) { cb(); } +var mockPush = function(remote, branch, flags, cb) { cb();} var mockGit = function() { return { - createTag: mockCreateTag + createTag: mockCreateTag, + push: mockPush }; }; @@ -194,7 +196,8 @@ describe('redis plugin', function() { }; var config = { - revisionKey: '123abc' + revisionKey: '123abc', + deployBranch: 'master' }; var context = { From 51045d09af0436c0558817208444b6f58ba1ad30 Mon Sep 17 00:00:00 2001 From: Imran Ismail Date: Fri, 8 Jan 2016 18:49:46 +0800 Subject: [PATCH 3/3] fix naming consistency --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2fbffce..49c0e67 100644 --- a/index.js +++ b/index.js @@ -34,9 +34,9 @@ module.exports = { var _this = this; return new Promise(function(resolve, reject) { - repo.createTag(tag, function(e) { - if (e) { - reject(e); + repo.createTag(tag, function(error) { + if (error) { + reject(error); } else { resolve(repo, tag); } @@ -52,7 +52,7 @@ module.exports = { } }); }, function(error) { - _this.log(e, { color: 'red' }); + _this.log(error, { color: 'red' }); }); } });