nci/lib/scm/base.js

86 lines
1.6 KiB
JavaScript
Raw Normal View History

'use strict';
var EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits,
_ = require('underscore');
2014-05-10 10:19:47 +00:00
function Scm(params) {
var self = this;
EventEmitter.call(self);
self.repository = params.repository;
self.cwd = params.cwd;
if (!self.repository && !self.cwd) {
throw new Error('`repository` or `cwd` must be set');
}
self.command = params.command;
2016-02-28 19:13:24 +00:00
if (!self.command) throw new Error('`command` is required');
self.command.setParams({
collectOut: true,
emitIn: true,
attachStderr: true
});
self.command.on('stdin', function(data) {
self.emit('stdin', data);
});
}
exports.Scm = Scm;
inherits(Scm, EventEmitter);
2016-02-27 20:47:36 +00:00
Scm.prototype._run = function(params, callback) {
if (this.cwd) {
params.options = params.options || {};
params.options.cwd = this.cwd;
}
this.command.run(params, callback);
};
/**
* Clone repository to the `dst` update to `rev` and set `this.cwd` to `dst`
*/
2014-05-10 10:19:47 +00:00
Scm.prototype.clone = function(dst, rev, callback) {
};
/**
* Pull changes from remote repository without update
*/
2014-05-10 10:19:47 +00:00
Scm.prototype.pull = function(rev, callback) {
};
/**
* Returns info (in changes format) about current revision
*/
Scm.prototype.getCurrent = function(callback) {
};
/**
* Returns array of changes between revisions
*/
2014-05-10 10:19:47 +00:00
Scm.prototype.getChanges = function(rev1, rev2, callback) {
};
2015-06-23 19:18:13 +00:00
/**
* Returns info (in changes format) about target revision
*/
Scm.prototype.getRev = function(rev, callback) {
this.getChanges(rev, rev, function(err, changes) {
callback(err, !err && changes[0]);
});
};
/**
* Updates to revision and throw away all local changes
*/
2014-05-10 10:19:47 +00:00
Scm.prototype.update = function(rev, callback) {
};