Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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*/) {
Expand All @@ -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);
repo.createTag(tag, function(error) {
if (error) {
reject(error);
} 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(error, { color: 'red' });
});
}
});
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/index-nodetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
};

Expand Down Expand Up @@ -194,7 +196,8 @@ describe('redis plugin', function() {
};

var config = {
revisionKey: '123abc'
revisionKey: '123abc',
deployBranch: 'master'
};

var context = {
Expand Down