catch revisions by tag

This commit is contained in:
oleg 2015-06-28 13:23:34 +03:00
parent 15e5191ca5
commit de5ddcbc88
3 changed files with 105 additions and 36 deletions

View File

@ -17,7 +17,7 @@ work in progress...
* Mail and jabber notifications (with commits, current step and error) * Mail and jabber notifications (with commits, current step and error)
* ~~Rename notification strategies according to statuses~~ * ~~Rename notification strategies according to statuses~~
* Work with git * Work with git
* Build every commit, commit with tag, etc * ~~Build every commit, commit with tag, etc~~
* Safe id and build numbers generation * Safe id and build numbers generation
* Scheduler * Scheduler
* ~~Better tests coverage~~ * ~~Better tests coverage~~

View File

@ -72,6 +72,21 @@ Executor.prototype._getTarget = function(rev, changes) {
}); });
} }
var tag = catchRev.tag;
if (tag) {
index = _(changes).findIndex(function(change) {
if (change.tags) {
if (_(tag).isRegExp()) {
return _(change.tags).find(function(changeTag) {
return tag.test(changeTag);
});
} else {
return _(change.tags).contains(tag);
}
}
});
}
if (index !== -1) { if (index !== -1) {
result.rev = changes[index].id; result.rev = changes[index].id;
result.changes = changes.slice(0, index + 1); result.changes = changes.slice(0, index + 1);

View File

@ -67,13 +67,15 @@ var expect = require('expect.js'),
); );
}); });
describe('with scm rev default and catch rev "first revision"', function() { _(['first revision', /^first revision$/]).each(function(comment) {
describe('with scm rev default and catch rev ' + comment, function() {
before(clearWorkspace); before(clearWorkspace);
it('instance should be created without errors', function() { it('instance should be created without errors', function() {
executor = createExecutor(makeExecutorParams({ executor = createExecutor(makeExecutorParams({
project: { project: {
catchRev: {comment: 'first revision'} catchRev: {comment: comment}
} }
})); }));
}); });
@ -111,6 +113,58 @@ var expect = require('expect.js'),
}); });
} }
); );
});
});
_(['second revision', /^second revision$/]).each(function(tag) {
describe('with scm rev default and catch tag ' + tag, function() {
before(clearWorkspace);
it('instance should be created without errors', function() {
executor = createExecutor(makeExecutorParams({
project: {
catchRev: {tag: tag}
}
}));
});
it('should run without errors', function(done) {
executor.run({}, function(err) {
expect(err).not.ok();
done();
});
executor.on('scmData', function(data) {
scmData = data;
});
});
it('scm data should be rev: 2, changes: [0, 2], not latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[2],
changes: mercurialRevs.slice(0, 3).reverse(),
isLatest: false
});
});
it('should run it again without errors', function(done) {
executor.run({}, done);
});
it(
'scm data should be rev: last, changes: [3-last], is latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[mercurialRevs.length - 1],
changes: mercurialRevs.slice(3).reverse(),
isLatest: true
});
}
);
});
}); });