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)
* ~~Rename notification strategies according to statuses~~
* Work with git
* Build every commit, commit with tag, etc
* ~~Build every commit, commit with tag, etc~~
* Safe id and build numbers generation
* Scheduler
* ~~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) {
result.rev = changes[index].id;
result.changes = changes.slice(0, index + 1);

View File

@ -67,50 +67,104 @@ var expect = require('expect.js'),
);
});
describe('with scm rev default and catch rev "first revision"', function() {
before(clearWorkspace);
_(['first revision', /^first revision$/]).each(function(comment) {
it('instance should be created without errors', function() {
executor = createExecutor(makeExecutorParams({
project: {
catchRev: {comment: 'first revision'}
describe('with scm rev default and catch rev ' + comment, function() {
before(clearWorkspace);
it('instance should be created without errors', function() {
executor = createExecutor(makeExecutorParams({
project: {
catchRev: {comment: comment}
}
}));
});
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: 1, changes: [0, 1], not latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[1],
changes: mercurialRevs.slice(0, 2).reverse(),
isLatest: false
});
});
it('should run it again without errors', function(done) {
executor.run({}, done);
});
it(
'scm data should be rev: last, changes: [2-last], is latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[mercurialRevs.length - 1],
changes: mercurialRevs.slice(2).reverse(),
isLatest: true
});
}
}));
);
});
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: 1, changes: [0, 1], not latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[1],
changes: mercurialRevs.slice(0, 2).reverse(),
isLatest: false
_(['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('should run it again without errors', function(done) {
executor.run({}, done);
});
it(
'scm data should be rev: last, changes: [2-last], is latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[mercurialRevs.length - 1],
changes: mercurialRevs.slice(2).reverse(),
isLatest: true
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
});
}
);
});
});