mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 17:39:15 +00:00
catch revisions by tag
This commit is contained in:
parent
15e5191ca5
commit
de5ddcbc88
@ -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~~
|
||||
|
@ -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);
|
||||
|
124
test/executor.js
124
test/executor.js
@ -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
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user