mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
almost can do tests
This commit is contained in:
parent
565142048c
commit
ddf399e099
10 changed files with 288 additions and 163 deletions
|
@ -1,23 +1,24 @@
|
|||
var _;
|
||||
var _ = require('underscore');
|
||||
var Backbone;
|
||||
// horrible hack to get localStorage Backbone plugin
|
||||
if (!require('../util').isBrowser()) {
|
||||
_ = require('underscore');
|
||||
Backbone = require('backbone');
|
||||
} else {
|
||||
Backbone = window.Backbone;
|
||||
_ = window._;
|
||||
}
|
||||
|
||||
var GitEngine = require('../git').GitEngine;
|
||||
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
||||
var GitVisuals = require('../visuals').GitVisuals;
|
||||
var TreeCompare = require('../git/treeCompare').TreeCompare;
|
||||
|
||||
var Collections = require('../models/collections');
|
||||
var CommitCollection = Collections.CommitCollection;
|
||||
var BranchCollection = Collections.BranchCollection;
|
||||
var Command = require('../models/commandModel').Command;
|
||||
|
||||
var mock = require('../util/mock').mock;
|
||||
var util = require('../util');
|
||||
|
||||
var HeadlessGit = function() {
|
||||
this.init();
|
||||
|
@ -26,6 +27,7 @@ var HeadlessGit = function() {
|
|||
HeadlessGit.prototype.init = function() {
|
||||
this.commitCollection = new CommitCollection();
|
||||
this.branchCollection = new BranchCollection();
|
||||
this.treeCompare = new TreeCompare();
|
||||
|
||||
// here we mock visuals and animation factory so the git engine
|
||||
// is headless
|
||||
|
@ -42,5 +44,16 @@ HeadlessGit.prototype.init = function() {
|
|||
this.gitEngine.init();
|
||||
};
|
||||
|
||||
HeadlessGit.prototype.sendCommand = function(value) {
|
||||
util.splitTextCommand(value, function(commandStr) {
|
||||
var commandObj = new Command({
|
||||
rawStr: commandStr
|
||||
});
|
||||
console.log('dispatching command', value);
|
||||
var done = function() {};
|
||||
this.gitEngine.dispatch(commandObj, done);
|
||||
}, this);
|
||||
};
|
||||
|
||||
exports.HeadlessGit = HeadlessGit;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue