mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 23:48:34 +02:00
Trying to be able to test in node GAHHHH
This commit is contained in:
parent
c9fb851ad6
commit
aadeab8299
14 changed files with 4186 additions and 69 deletions
4164
build/bundle.js
4164
build/bundle.js
File diff suppressed because it is too large
Load diff
|
@ -9,5 +9,10 @@
|
||||||
"grunt-jasmine-node": "latest",
|
"grunt-jasmine-node": "latest",
|
||||||
"grunt-hash": "latest",
|
"grunt-hash": "latest",
|
||||||
"grunt-rm": "~0.0.3"
|
"grunt-rm": "~0.0.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"backbone": "~0.9.9",
|
||||||
|
"underscore": "~1.4.3",
|
||||||
|
"jquery": "~1.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var GitEngine = require('../git').GitEngine;
|
var GitEngine = require('../git').GitEngine;
|
||||||
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
||||||
var GitVisuals = require('../visuals').GitVisuals;
|
var GitVisuals = require('../visuals').GitVisuals;
|
||||||
|
@ -25,7 +30,8 @@ HeadlessGit.prototype.init = function() {
|
||||||
collection: this.commitCollection,
|
collection: this.commitCollection,
|
||||||
branches: this.branchCollection,
|
branches: this.branchCollection,
|
||||||
gitVisuals: gitVisuals,
|
gitVisuals: gitVisuals,
|
||||||
animationFactory: animationFactory
|
animationFactory: animationFactory,
|
||||||
|
events: _.clone(Backbone.Events)
|
||||||
});
|
});
|
||||||
this.gitEngine.init();
|
this.gitEngine.init();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var AnimationFactoryModule = require('../visuals/animation/animationFactory');
|
var AnimationFactoryModule = require('../visuals/animation/animationFactory');
|
||||||
var Main = require('../app');
|
|
||||||
var AnimationQueue = require('../visuals/animation').AnimationQueue;
|
var AnimationQueue = require('../visuals/animation').AnimationQueue;
|
||||||
var InteractiveRebaseView = require('../views/miscViews').InteractiveRebaseView;
|
|
||||||
|
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
var GitError = Errors.GitError;
|
var GitError = Errors.GitError;
|
||||||
|
@ -23,6 +26,7 @@ function GitEngine(options) {
|
||||||
this.branchCollection = options.branches;
|
this.branchCollection = options.branches;
|
||||||
this.commitCollection = options.collection;
|
this.commitCollection = options.collection;
|
||||||
this.gitVisuals = options.gitVisuals;
|
this.gitVisuals = options.gitVisuals;
|
||||||
|
this.events = options.events;
|
||||||
this.animationFactory = options.animationFactory ||
|
this.animationFactory = options.animationFactory ||
|
||||||
new AnimationFactoryModule.AnimationFactory();
|
new AnimationFactoryModule.AnimationFactory();
|
||||||
|
|
||||||
|
@ -31,7 +35,7 @@ function GitEngine(options) {
|
||||||
this.commandOptions = {};
|
this.commandOptions = {};
|
||||||
this.generalArgs = [];
|
this.generalArgs = [];
|
||||||
|
|
||||||
Main.getEvents().on('processCommand', _.bind(this.dispatch, this));
|
this.events.on('processCommand', _.bind(this.dispatch, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
GitEngine.prototype.defaultInit = function() {
|
GitEngine.prototype.defaultInit = function() {
|
||||||
|
@ -1014,6 +1018,7 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
|
||||||
this.animationQueue.start();
|
this.animationQueue.start();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
var InteractiveRebaseView = require('../views/miscViews').InteractiveRebaseView;
|
||||||
new InteractiveRebaseView({
|
new InteractiveRebaseView({
|
||||||
callback: callback,
|
callback: callback,
|
||||||
toRebase: toRebase,
|
toRebase: toRebase,
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var Commit = require('../git').Commit;
|
var Commit = require('../git').Commit;
|
||||||
var Branch = require('../git').Branch;
|
var Branch = require('../git').Branch;
|
||||||
|
|
||||||
var Main = require('../app');
|
|
||||||
var Command = require('../models/commandModel').Command;
|
var Command = require('../models/commandModel').Command;
|
||||||
var CommandEntry = require('../models/commandModel').CommandEntry;
|
var CommandEntry = require('../models/commandModel').CommandEntry;
|
||||||
var TIME = require('../util/constants').TIME;
|
var TIME = require('../util/constants').TIME;
|
||||||
|
@ -20,7 +24,7 @@ var BranchCollection = Backbone.Collection.extend({
|
||||||
|
|
||||||
var CommandEntryCollection = Backbone.Collection.extend({
|
var CommandEntryCollection = Backbone.Collection.extend({
|
||||||
model: CommandEntry,
|
model: CommandEntry,
|
||||||
localStorage: new Backbone.LocalStorage('CommandEntries')
|
localStorage: (Backbone.LocalStorage) ? new Backbone.LocalStorage('CommandEntries') : null
|
||||||
});
|
});
|
||||||
|
|
||||||
var CommandBuffer = Backbone.Model.extend({
|
var CommandBuffer = Backbone.Model.extend({
|
||||||
|
@ -74,6 +78,7 @@ var CommandBuffer = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
if (!popped.get('error')) {
|
if (!popped.get('error')) {
|
||||||
// pass in a callback, so when this command is "done" we will process the next.
|
// pass in a callback, so when this command is "done" we will process the next.
|
||||||
|
var Main = require('../app');
|
||||||
Main.getEvents().trigger('processCommand', popped, callback);
|
Main.getEvents().trigger('processCommand', popped, callback);
|
||||||
} else {
|
} else {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
|
|
||||||
var CommandProcessError = Errors.CommandProcessError;
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
@ -363,10 +368,9 @@ var CommandEntry = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
text: ''
|
text: ''
|
||||||
},
|
},
|
||||||
localStorage: new Backbone.LocalStorage('CommandEntries')
|
// stub out if no plugin available
|
||||||
|
localStorage: (Backbone.LocalStorage) ? new Backbone.LocalStorage('CommandEntries') : null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
exports.CommandEntry = CommandEntry;
|
exports.CommandEntry = CommandEntry;
|
||||||
exports.Command = Command;
|
exports.Command = Command;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var MyError = Backbone.Model.extend({
|
var MyError = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
type: 'MyError',
|
type: 'MyError',
|
||||||
|
|
4
src/js/util/index.js
Normal file
4
src/js/util/index.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
exports.isBrowser = function() {
|
||||||
|
return (typeof window === undefined);
|
||||||
|
};
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
var Animation = require('./index').Animation;
|
var Animation = require('./index').Animation;
|
||||||
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
var GRAPHICS = require('../../util/constants').GRAPHICS;
|
||||||
|
|
||||||
|
if (!require('../../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
// essentially a static class
|
// essentially a static class
|
||||||
var AnimationFactory = function() {
|
var AnimationFactory = function() {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
var GLOBAL = require('../../util/constants').GLOBAL;
|
var GLOBAL = require('../../util/constants').GLOBAL;
|
||||||
|
|
||||||
|
if (!require('../../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var Animation = Backbone.Model.extend({
|
var Animation = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
duration: 300,
|
duration: 300,
|
||||||
|
@ -82,4 +87,3 @@ var AnimationQueue = Backbone.Model.extend({
|
||||||
|
|
||||||
exports.Animation = Animation;
|
exports.Animation = Animation;
|
||||||
exports.AnimationQueue = AnimationQueue;
|
exports.AnimationQueue = AnimationQueue;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
var Main = require('../app');
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var GRAPHICS = require('../util/constants').GRAPHICS;
|
var GRAPHICS = require('../util/constants').GRAPHICS;
|
||||||
var GLOBAL = require('../util/constants').GLOBAL;
|
var GLOBAL = require('../util/constants').GLOBAL;
|
||||||
|
|
||||||
|
@ -27,6 +31,8 @@ var Visualization = Backbone.View.extend({
|
||||||
|
|
||||||
paperInitialize: function(paper, options) {
|
paperInitialize: function(paper, options) {
|
||||||
this.paper = paper;
|
this.paper = paper;
|
||||||
|
var Main = require('../app');
|
||||||
|
this.events = Main.getEvents();
|
||||||
|
|
||||||
this.commitCollection = new CommitCollection();
|
this.commitCollection = new CommitCollection();
|
||||||
this.branchCollection = new BranchCollection();
|
this.branchCollection = new BranchCollection();
|
||||||
|
@ -41,7 +47,8 @@ var Visualization = Backbone.View.extend({
|
||||||
this.gitEngine = new GitEngine({
|
this.gitEngine = new GitEngine({
|
||||||
collection: this.commitCollection,
|
collection: this.commitCollection,
|
||||||
branches: this.branchCollection,
|
branches: this.branchCollection,
|
||||||
gitVisuals: this.gitVisuals
|
gitVisuals: this.gitVisuals,
|
||||||
|
events: this.events
|
||||||
});
|
});
|
||||||
this.gitEngine.init();
|
this.gitEngine.init();
|
||||||
this.gitVisuals.assignGitEngine(this.gitEngine);
|
this.gitVisuals.assignGitEngine(this.gitEngine);
|
||||||
|
@ -91,7 +98,8 @@ function GitVisuals(options) {
|
||||||
this.branchCollection.on('remove', this.removeBranch, this);
|
this.branchCollection.on('remove', this.removeBranch, this);
|
||||||
this.deferred = [];
|
this.deferred = [];
|
||||||
|
|
||||||
Main.getEvents().on('refreshTree', _.bind(
|
this.events = require('../app').getEvents();
|
||||||
|
this.events.on('refreshTree', _.bind(
|
||||||
this.refreshTree, this
|
this.refreshTree, this
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -536,7 +544,7 @@ GitVisuals.prototype.calcDepthRecursive = function(commit, depth) {
|
||||||
GitVisuals.prototype.canvasResize = _.debounce(function(width, height) {
|
GitVisuals.prototype.canvasResize = _.debounce(function(width, height) {
|
||||||
// refresh when we are ready
|
// refresh when we are ready
|
||||||
if (GLOBAL.isAnimating) {
|
if (GLOBAL.isAnimating) {
|
||||||
Main.getEvents().trigger('processCommandFromEvent', 'refresh');
|
this.events.trigger('processCommandFromEvent', 'refresh');
|
||||||
} else {
|
} else {
|
||||||
this.refreshTree();
|
this.refreshTree();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
var Main = require('../app');
|
if (!require('../util').isBrowser()) {
|
||||||
|
var _ = require('underscore');
|
||||||
|
var Backbone = require('backbone');
|
||||||
|
}
|
||||||
|
|
||||||
var GRAPHICS = require('../util/constants').GRAPHICS;
|
var GRAPHICS = require('../util/constants').GRAPHICS;
|
||||||
|
|
||||||
var randomHueString = function() {
|
var randomHueString = function() {
|
||||||
|
@ -712,6 +716,7 @@ var VisNode = VisBase.extend({
|
||||||
|
|
||||||
attachClickHandlers: function() {
|
attachClickHandlers: function() {
|
||||||
var commandStr = 'git show ' + this.get('commit').get('id');
|
var commandStr = 'git show ' + this.get('commit').get('id');
|
||||||
|
var Main = require('../app');
|
||||||
_.each([this.get('circle'), this.get('text')], function(rObj) {
|
_.each([this.get('circle'), this.get('text')], function(rObj) {
|
||||||
rObj.click(function() {
|
rObj.click(function() {
|
||||||
Main.getEvents().trigger('processCommandFromEvent', commandStr);
|
Main.getEvents().trigger('processCommandFromEvent', commandStr);
|
||||||
|
|
2
todo.txt
2
todo.txt
|
@ -8,7 +8,7 @@ Big Graphic things:
|
||||||
Medium things:
|
Medium things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
- gitEngine loads from tree immediately, not the weird thing we have now!
|
- gitEngine loads from tree immediately, not the weird thing we have now!
|
||||||
- headless git
|
- headless Git for testing (send it commands and expected trees)
|
||||||
|
|
||||||
Small things to implement:
|
Small things to implement:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue