mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 09: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)
|
* 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~~
|
||||||
|
@ -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);
|
||||||
|
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() {
|
_(['first revision', /^first revision$/]).each(function(comment) {
|
||||||
before(clearWorkspace);
|
|
||||||
|
|
||||||
it('instance should be created without errors', function() {
|
describe('with scm rev default and catch rev ' + comment, function() {
|
||||||
executor = createExecutor(makeExecutorParams({
|
before(clearWorkspace);
|
||||||
project: {
|
|
||||||
catchRev: {comment: 'first revision'}
|
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',
|
_(['second revision', /^second revision$/]).each(function(tag) {
|
||||||
function() {
|
|
||||||
expect(scmData).eql({
|
describe('with scm rev default and catch tag ' + tag, function() {
|
||||||
rev: mercurialRevs[1],
|
before(clearWorkspace);
|
||||||
changes: mercurialRevs.slice(0, 2).reverse(),
|
|
||||||
isLatest: false
|
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) {
|
it('scm data should be rev: 2, changes: [0, 2], not latest',
|
||||||
executor.run({}, done);
|
function() {
|
||||||
});
|
expect(scmData).eql({
|
||||||
|
rev: mercurialRevs[2],
|
||||||
it(
|
changes: mercurialRevs.slice(0, 3).reverse(),
|
||||||
'scm data should be rev: last, changes: [2-last], is latest',
|
isLatest: false
|
||||||
function() {
|
});
|
||||||
expect(scmData).eql({
|
|
||||||
rev: mercurialRevs[mercurialRevs.length - 1],
|
|
||||||
changes: mercurialRevs.slice(2).reverse(),
|
|
||||||
isLatest: true
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
);
|
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