Skip to content
Open
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
39 changes: 24 additions & 15 deletions lib/data-generators/git-tag-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,33 @@ module.exports = CoreObject.extend({
},

generate: function() {
var commitHashLength = this._plugin.readConfig('commitHashLength');
var separator = this._plugin.readConfig('separator');
var info = gitRepoInfo();
var providedTag = this._plugin.readConfig('tag');

if (info === null || info.root === null) {
return RSVP.reject('Could not find git repository');
}
if (providedTag) {
return RSVP.resolve({
revisionKey: providedTag,
timestamp: new Date().toISOString()
});
} else {
var commitHashLength = this._plugin.readConfig('commitHashLength');
var separator = this._plugin.readConfig('separator');
var info = gitRepoInfo();

var tag = info.lastTag;
var sha = info.sha.slice(0, commitHashLength);
if (info === null || info.root === null) {
return RSVP.reject('Could not find git repository');
}

if (!tag || !sha) {
return RSVP.reject('Could not build revision with tag `' + tag + '` and commit hash `' + sha + '`');
}
var tag = info.lastTag;
var sha = info.sha.slice(0, commitHashLength);

return RSVP.resolve({
revisionKey: tag + separator + sha,
timestamp: new Date().toISOString()
});
if (!tag || !sha) {
return RSVP.reject('Could not build revision with tag `' + tag + '` and commit hash `' + sha + '`');
}

return RSVP.resolve({
revisionKey: tag + separator + sha,
timestamp: new Date().toISOString()
});
}
}
});