mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-01 10:14:28 +02:00
moving around
This commit is contained in:
parent
a180426cfb
commit
4046916432
8 changed files with 317 additions and 209 deletions
38
src/js/level/disableMap.js
Normal file
38
src/js/level/disableMap.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
var _ = require('underscore');
|
||||
|
||||
var GitCommands = require('../git/commands');
|
||||
|
||||
var Errors = require('../util/errors');
|
||||
var GitError = Errors.GitError;
|
||||
|
||||
function DisabledMap(options) {
|
||||
this.disabledMap = options.disabledMap || {
|
||||
'cherry-pick': true,
|
||||
'rebase': true
|
||||
};
|
||||
}
|
||||
|
||||
DisabledMap.prototype.getInstantCommands = function() {
|
||||
// this produces an array of regex / function pairs that can be
|
||||
// piped into a parse waterfall to disable certain git commmands
|
||||
// :D
|
||||
var instants = [];
|
||||
var onMatch = function() {
|
||||
throw new GitError({
|
||||
msg: 'That git command is disabled for this level!'
|
||||
});
|
||||
};
|
||||
|
||||
_.each(this.disabledMap, function(val, disabledCommand) {
|
||||
var gitRegex = GitCommands.regexMap[disabledCommand];
|
||||
if (!gitRegex) {
|
||||
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
||||
' has no regex matching');
|
||||
}
|
||||
instants.push([gitRegex, onMatch]);
|
||||
});
|
||||
return instants;
|
||||
};
|
||||
|
||||
exports.DisabledMap = DisabledMap;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue