mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
YAY looking a lot better, need to do rest of filter error
This commit is contained in:
parent
01fb9ec25b
commit
82d9e7a223
5 changed files with 222 additions and 45 deletions
178
build/bundle.js
178
build/bundle.js
|
@ -8433,6 +8433,19 @@ var GitError = exports.GitError = MyError.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var filterError = function(err) {
|
||||||
|
if (err instanceof CommandProcessError ||
|
||||||
|
err instanceof GitError ||
|
||||||
|
err instanceof CommandResult ||
|
||||||
|
err instanceof Warning) {
|
||||||
|
// yay! one of ours
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.filterError = filterError;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11054,15 +11067,9 @@ var Command = Backbone.Model.extend({
|
||||||
try {
|
try {
|
||||||
this.parse();
|
this.parse();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof CommandProcessError ||
|
Errors.filterError(err);
|
||||||
err instanceof GitError ||
|
// errorChanged() will handle status and all of that
|
||||||
err instanceof CommandResult ||
|
this.set('error', err);
|
||||||
err instanceof Warning) {
|
|
||||||
// errorChanged() will handle status and all of that
|
|
||||||
this.set('error', err);
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -11161,6 +11168,9 @@ var Command = Backbone.Model.extend({
|
||||||
throw new CommandResult({msg: ""});
|
throw new CommandResult({msg: ""});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str = GitCommands.expandShortcut(str);
|
||||||
|
this.set('rawStr', str);
|
||||||
|
|
||||||
// then check if it's one of our sandbox commands
|
// then check if it's one of our sandbox commands
|
||||||
_.each(this.getSandboxCommands(), function(tuple) {
|
_.each(this.getSandboxCommands(), function(tuple) {
|
||||||
var regex = tuple[0];
|
var regex = tuple[0];
|
||||||
|
@ -11171,9 +11181,6 @@ var Command = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
str = GitCommands.expandShortcut(str);
|
|
||||||
this.set('rawStr', str);
|
|
||||||
|
|
||||||
// see if begins with git
|
// see if begins with git
|
||||||
if (str.slice(0,3) !== 'git') {
|
if (str.slice(0,3) !== 'git') {
|
||||||
throw new CommandProcessError({
|
throw new CommandProcessError({
|
||||||
|
@ -11347,7 +11354,8 @@ var getShortcutMap = function() {
|
||||||
'git add': /^ga($|\s)/,
|
'git add': /^ga($|\s)/,
|
||||||
'git checkout': /^go($|\s)/,
|
'git checkout': /^go($|\s)/,
|
||||||
'git rebase': /^gr($|\s)/,
|
'git rebase': /^gr($|\s)/,
|
||||||
'git branch': /^gb($|\s)/
|
'git branch': /^gb($|\s)/,
|
||||||
|
'git status': /^gs($|\s)/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13750,6 +13758,13 @@ require.define("/src/js/level/inputWaterfall.js",function(require,module,exports
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
var GitCommands = require('../git/commands');
|
||||||
|
|
||||||
|
var Errors = require('../util/errors');
|
||||||
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
var GitError = Errors.GitError;
|
||||||
|
var Warning = Errors.Warning;
|
||||||
|
var CommandResult = Errors.CommandResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class supports a few things we need for levels:
|
* This class supports a few things we need for levels:
|
||||||
|
@ -13761,7 +13776,10 @@ var Main = require('../app');
|
||||||
function InputWaterfall(options) {
|
function InputWaterfall(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.listenEvent = options.listenEvent || 'processCommand';
|
this.listenEvent = options.listenEvent || 'processCommand';
|
||||||
this.disabledMap = options.disabledMap || {};
|
this.disabledMap = options.disabledMap || {
|
||||||
|
'git cherry-pick': true,
|
||||||
|
'git rebase': true
|
||||||
|
};
|
||||||
|
|
||||||
console.log('made');
|
console.log('made');
|
||||||
|
|
||||||
|
@ -13777,11 +13795,52 @@ InputWaterfall.prototype.mute = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
InputWaterfall.prototype.process = function(command, callback) {
|
InputWaterfall.prototype.process = function(command, callback) {
|
||||||
console.log('processing');
|
console.log('processing', command.get('rawStr'));
|
||||||
|
|
||||||
|
if (this.checkDisabledMap(command)) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// for now, just immediately fire it
|
// for now, just immediately fire it
|
||||||
Main.getEvents().trigger('processGitCommand', command, callback);
|
Main.getEvents().trigger('processGitCommand', command, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputWaterfall.prototype.sliceGitOff = function(str) {
|
||||||
|
return str.slice('git '.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputWaterfall.prototype.checkDisabledMap = function(command) {
|
||||||
|
try {
|
||||||
|
this.loopDisabledMap(command);
|
||||||
|
} catch(err) {
|
||||||
|
command.set('error', err);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// not needed explicitly, but included for clarity
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
InputWaterfall.prototype.loopDisabledMap = function(command) {
|
||||||
|
var toTest = this.sliceGitOff(command.get('rawStr'));
|
||||||
|
var regexMap = GitCommands.getRegexMap();
|
||||||
|
|
||||||
|
_.each(this.disabledMap, function(val, disabledGitCommand) {
|
||||||
|
disabledGitCommand = this.sliceGitOff(disabledGitCommand);
|
||||||
|
|
||||||
|
var regex = regexMap[disabledGitCommand];
|
||||||
|
if (!regex) {
|
||||||
|
console.warn('wut, no regex for command', disabledGitCommand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regex.test(toTest)) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: 'That git command is disabled for this level!'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
exports.InputWaterfall = InputWaterfall;
|
exports.InputWaterfall = InputWaterfall;
|
||||||
|
|
||||||
|
|
||||||
|
@ -14142,7 +14201,8 @@ var getShortcutMap = function() {
|
||||||
'git add': /^ga($|\s)/,
|
'git add': /^ga($|\s)/,
|
||||||
'git checkout': /^go($|\s)/,
|
'git checkout': /^go($|\s)/,
|
||||||
'git rebase': /^gr($|\s)/,
|
'git rebase': /^gr($|\s)/,
|
||||||
'git branch': /^gb($|\s)/
|
'git branch': /^gb($|\s)/,
|
||||||
|
'git status': /^gs($|\s)/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16023,6 +16083,13 @@ require.define("/src/js/level/inputWaterfall.js",function(require,module,exports
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
var GitCommands = require('../git/commands');
|
||||||
|
|
||||||
|
var Errors = require('../util/errors');
|
||||||
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
var GitError = Errors.GitError;
|
||||||
|
var Warning = Errors.Warning;
|
||||||
|
var CommandResult = Errors.CommandResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class supports a few things we need for levels:
|
* This class supports a few things we need for levels:
|
||||||
|
@ -16034,7 +16101,10 @@ var Main = require('../app');
|
||||||
function InputWaterfall(options) {
|
function InputWaterfall(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.listenEvent = options.listenEvent || 'processCommand';
|
this.listenEvent = options.listenEvent || 'processCommand';
|
||||||
this.disabledMap = options.disabledMap || {};
|
this.disabledMap = options.disabledMap || {
|
||||||
|
'git cherry-pick': true,
|
||||||
|
'git rebase': true
|
||||||
|
};
|
||||||
|
|
||||||
console.log('made');
|
console.log('made');
|
||||||
|
|
||||||
|
@ -16050,11 +16120,52 @@ InputWaterfall.prototype.mute = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
InputWaterfall.prototype.process = function(command, callback) {
|
InputWaterfall.prototype.process = function(command, callback) {
|
||||||
console.log('processing');
|
console.log('processing', command.get('rawStr'));
|
||||||
|
|
||||||
|
if (this.checkDisabledMap(command)) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// for now, just immediately fire it
|
// for now, just immediately fire it
|
||||||
Main.getEvents().trigger('processGitCommand', command, callback);
|
Main.getEvents().trigger('processGitCommand', command, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputWaterfall.prototype.sliceGitOff = function(str) {
|
||||||
|
return str.slice('git '.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputWaterfall.prototype.checkDisabledMap = function(command) {
|
||||||
|
try {
|
||||||
|
this.loopDisabledMap(command);
|
||||||
|
} catch(err) {
|
||||||
|
command.set('error', err);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// not needed explicitly, but included for clarity
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
InputWaterfall.prototype.loopDisabledMap = function(command) {
|
||||||
|
var toTest = this.sliceGitOff(command.get('rawStr'));
|
||||||
|
var regexMap = GitCommands.getRegexMap();
|
||||||
|
|
||||||
|
_.each(this.disabledMap, function(val, disabledGitCommand) {
|
||||||
|
disabledGitCommand = this.sliceGitOff(disabledGitCommand);
|
||||||
|
|
||||||
|
var regex = regexMap[disabledGitCommand];
|
||||||
|
if (!regex) {
|
||||||
|
console.warn('wut, no regex for command', disabledGitCommand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regex.test(toTest)) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: 'That git command is disabled for this level!'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
exports.InputWaterfall = InputWaterfall;
|
exports.InputWaterfall = InputWaterfall;
|
||||||
|
|
||||||
|
|
||||||
|
@ -16249,15 +16360,9 @@ var Command = Backbone.Model.extend({
|
||||||
try {
|
try {
|
||||||
this.parse();
|
this.parse();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof CommandProcessError ||
|
Errors.filterError(err);
|
||||||
err instanceof GitError ||
|
// errorChanged() will handle status and all of that
|
||||||
err instanceof CommandResult ||
|
this.set('error', err);
|
||||||
err instanceof Warning) {
|
|
||||||
// errorChanged() will handle status and all of that
|
|
||||||
this.set('error', err);
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -16356,6 +16461,9 @@ var Command = Backbone.Model.extend({
|
||||||
throw new CommandResult({msg: ""});
|
throw new CommandResult({msg: ""});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str = GitCommands.expandShortcut(str);
|
||||||
|
this.set('rawStr', str);
|
||||||
|
|
||||||
// then check if it's one of our sandbox commands
|
// then check if it's one of our sandbox commands
|
||||||
_.each(this.getSandboxCommands(), function(tuple) {
|
_.each(this.getSandboxCommands(), function(tuple) {
|
||||||
var regex = tuple[0];
|
var regex = tuple[0];
|
||||||
|
@ -16366,9 +16474,6 @@ var Command = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
str = GitCommands.expandShortcut(str);
|
|
||||||
this.set('rawStr', str);
|
|
||||||
|
|
||||||
// see if begins with git
|
// see if begins with git
|
||||||
if (str.slice(0,3) !== 'git') {
|
if (str.slice(0,3) !== 'git') {
|
||||||
throw new CommandProcessError({
|
throw new CommandProcessError({
|
||||||
|
@ -16648,6 +16753,19 @@ var GitError = exports.GitError = MyError.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var filterError = function(err) {
|
||||||
|
if (err instanceof CommandProcessError ||
|
||||||
|
err instanceof GitError ||
|
||||||
|
err instanceof CommandResult ||
|
||||||
|
err instanceof Warning) {
|
||||||
|
// yay! one of ours
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.filterError = filterError;
|
||||||
|
|
||||||
});
|
});
|
||||||
require("/src/js/util/errors.js");
|
require("/src/js/util/errors.js");
|
||||||
|
|
|
@ -25,7 +25,8 @@ var getShortcutMap = function() {
|
||||||
'git add': /^ga($|\s)/,
|
'git add': /^ga($|\s)/,
|
||||||
'git checkout': /^go($|\s)/,
|
'git checkout': /^go($|\s)/,
|
||||||
'git rebase': /^gr($|\s)/,
|
'git rebase': /^gr($|\s)/,
|
||||||
'git branch': /^gb($|\s)/
|
'git branch': /^gb($|\s)/,
|
||||||
|
'git status': /^gs($|\s)/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,13 @@ var _ = require('underscore');
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
|
var GitCommands = require('../git/commands');
|
||||||
|
|
||||||
|
var Errors = require('../util/errors');
|
||||||
|
var CommandProcessError = Errors.CommandProcessError;
|
||||||
|
var GitError = Errors.GitError;
|
||||||
|
var Warning = Errors.Warning;
|
||||||
|
var CommandResult = Errors.CommandResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class supports a few things we need for levels:
|
* This class supports a few things we need for levels:
|
||||||
|
@ -13,7 +20,10 @@ var Main = require('../app');
|
||||||
function InputWaterfall(options) {
|
function InputWaterfall(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.listenEvent = options.listenEvent || 'processCommand';
|
this.listenEvent = options.listenEvent || 'processCommand';
|
||||||
this.disabledMap = options.disabledMap || {};
|
this.disabledMap = options.disabledMap || {
|
||||||
|
'git cherry-pick': true,
|
||||||
|
'git rebase': true
|
||||||
|
};
|
||||||
|
|
||||||
console.log('made');
|
console.log('made');
|
||||||
|
|
||||||
|
@ -29,10 +39,51 @@ InputWaterfall.prototype.mute = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
InputWaterfall.prototype.process = function(command, callback) {
|
InputWaterfall.prototype.process = function(command, callback) {
|
||||||
console.log('processing');
|
console.log('processing', command.get('rawStr'));
|
||||||
|
|
||||||
|
if (this.checkDisabledMap(command)) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// for now, just immediately fire it
|
// for now, just immediately fire it
|
||||||
Main.getEvents().trigger('processGitCommand', command, callback);
|
Main.getEvents().trigger('processGitCommand', command, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InputWaterfall.prototype.sliceGitOff = function(str) {
|
||||||
|
return str.slice('git '.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputWaterfall.prototype.checkDisabledMap = function(command) {
|
||||||
|
try {
|
||||||
|
this.loopDisabledMap(command);
|
||||||
|
} catch(err) {
|
||||||
|
command.set('error', err);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// not needed explicitly, but included for clarity
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
InputWaterfall.prototype.loopDisabledMap = function(command) {
|
||||||
|
var toTest = this.sliceGitOff(command.get('rawStr'));
|
||||||
|
var regexMap = GitCommands.getRegexMap();
|
||||||
|
|
||||||
|
_.each(this.disabledMap, function(val, disabledGitCommand) {
|
||||||
|
disabledGitCommand = this.sliceGitOff(disabledGitCommand);
|
||||||
|
|
||||||
|
var regex = regexMap[disabledGitCommand];
|
||||||
|
if (!regex) {
|
||||||
|
console.warn('wut, no regex for command', disabledGitCommand);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regex.test(toTest)) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: 'That git command is disabled for this level!'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
exports.InputWaterfall = InputWaterfall;
|
exports.InputWaterfall = InputWaterfall;
|
||||||
|
|
||||||
|
|
|
@ -77,15 +77,9 @@ var Command = Backbone.Model.extend({
|
||||||
try {
|
try {
|
||||||
this.parse();
|
this.parse();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof CommandProcessError ||
|
Errors.filterError(err);
|
||||||
err instanceof GitError ||
|
// errorChanged() will handle status and all of that
|
||||||
err instanceof CommandResult ||
|
this.set('error', err);
|
||||||
err instanceof Warning) {
|
|
||||||
// errorChanged() will handle status and all of that
|
|
||||||
this.set('error', err);
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -184,6 +178,9 @@ var Command = Backbone.Model.extend({
|
||||||
throw new CommandResult({msg: ""});
|
throw new CommandResult({msg: ""});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str = GitCommands.expandShortcut(str);
|
||||||
|
this.set('rawStr', str);
|
||||||
|
|
||||||
// then check if it's one of our sandbox commands
|
// then check if it's one of our sandbox commands
|
||||||
_.each(this.getSandboxCommands(), function(tuple) {
|
_.each(this.getSandboxCommands(), function(tuple) {
|
||||||
var regex = tuple[0];
|
var regex = tuple[0];
|
||||||
|
@ -194,9 +191,6 @@ var Command = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
str = GitCommands.expandShortcut(str);
|
|
||||||
this.set('rawStr', str);
|
|
||||||
|
|
||||||
// see if begins with git
|
// see if begins with git
|
||||||
if (str.slice(0,3) !== 'git') {
|
if (str.slice(0,3) !== 'git') {
|
||||||
throw new CommandProcessError({
|
throw new CommandProcessError({
|
||||||
|
|
|
@ -46,3 +46,16 @@ var GitError = exports.GitError = MyError.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var filterError = function(err) {
|
||||||
|
if (err instanceof CommandProcessError ||
|
||||||
|
err instanceof GitError ||
|
||||||
|
err instanceof CommandResult ||
|
||||||
|
err instanceof Warning) {
|
||||||
|
// yay! one of ours
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.filterError = filterError;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue