mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
add a vcs level to regex map
This commit is contained in:
parent
3abe620cf1
commit
54414925fa
4 changed files with 63 additions and 36 deletions
|
@ -9917,10 +9917,10 @@ var commands = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRegexMap: function() {
|
getRegexMap: function() {
|
||||||
var map = {};
|
var map = {'git': {}};
|
||||||
this.loop(function(config, name) {
|
this.loop(function(config, name, vcs) {
|
||||||
var displayName = 'git ' + (config.displayName || name);
|
var displayName = config.displayName || name;
|
||||||
map[displayName] = config.regex;
|
map[vcs][displayName] = config.regex;
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
|
@ -10427,13 +10427,15 @@ var parse = function(str) {
|
||||||
var options;
|
var options;
|
||||||
|
|
||||||
// see if we support this particular command
|
// see if we support this particular command
|
||||||
_.each(commands.getRegexMap(), function(regex, thisMethod) {
|
_.each(commands.getRegexMap(), function (map, thisVCS) {
|
||||||
|
_.each(map, function(regex, thisMethod) {
|
||||||
if (regex.exec(str)) {
|
if (regex.exec(str)) {
|
||||||
vcs = 'git'; // XXX get from regex map
|
vcs = thisVCS; // XXX get from regex map
|
||||||
options = str.slice(thisMethod.length + 1);
|
method = thisMethod;
|
||||||
method = thisMethod.slice(vcs.length + 1);
|
options = str.slice(vcs.length + 1 + method.length + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (!method) {
|
if (!method) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -14446,10 +14448,14 @@ var getAllCommands = function() {
|
||||||
|
|
||||||
var allCommands = _.extend(
|
var allCommands = _.extend(
|
||||||
{},
|
{},
|
||||||
GitCommands.commands.getRegexMap(),
|
|
||||||
require('../level').regexMap,
|
require('../level').regexMap,
|
||||||
regexMap
|
regexMap
|
||||||
);
|
);
|
||||||
|
_.each(GitCommands.commands.getRegexMap(), function(map, vcs) {
|
||||||
|
_.each(map, function(regex, method) {
|
||||||
|
allCommands[vcs + ' ' + method] = regex;
|
||||||
|
});
|
||||||
|
});
|
||||||
_.each(toDelete, function(key) {
|
_.each(toDelete, function(key) {
|
||||||
delete allCommands[key];
|
delete allCommands[key];
|
||||||
});
|
});
|
||||||
|
@ -18202,7 +18208,10 @@ DisabledMap.prototype.getInstantCommands = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
_.each(this.disabledMap, function(val, disabledCommand) {
|
_.each(this.disabledMap, function(val, disabledCommand) {
|
||||||
var gitRegex = GitCommands.commands.getRegexMap()[disabledCommand];
|
// XXX get hold of vcs from disabledMap
|
||||||
|
var vcs = 'git';
|
||||||
|
disabledCommand = disabledCommand.slice(vcs.length + 1);
|
||||||
|
var gitRegex = GitCommands.commands.getRegexMap()[vcs][disabledCommand];
|
||||||
if (!gitRegex) {
|
if (!gitRegex) {
|
||||||
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
||||||
' has no regex matching');
|
' has no regex matching');
|
||||||
|
@ -23803,10 +23812,10 @@ var commands = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRegexMap: function() {
|
getRegexMap: function() {
|
||||||
var map = {};
|
var map = {'git': {}};
|
||||||
this.loop(function(config, name) {
|
this.loop(function(config, name, vcs) {
|
||||||
var displayName = 'git ' + (config.displayName || name);
|
var displayName = config.displayName || name;
|
||||||
map[displayName] = config.regex;
|
map[vcs][displayName] = config.regex;
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
|
@ -24313,13 +24322,15 @@ var parse = function(str) {
|
||||||
var options;
|
var options;
|
||||||
|
|
||||||
// see if we support this particular command
|
// see if we support this particular command
|
||||||
_.each(commands.getRegexMap(), function(regex, thisMethod) {
|
_.each(commands.getRegexMap(), function (map, thisVCS) {
|
||||||
|
_.each(map, function(regex, thisMethod) {
|
||||||
if (regex.exec(str)) {
|
if (regex.exec(str)) {
|
||||||
vcs = 'git'; // XXX get from regex map
|
vcs = thisVCS; // XXX get from regex map
|
||||||
options = str.slice(thisMethod.length + 1);
|
method = thisMethod;
|
||||||
method = thisMethod.slice(vcs.length + 1);
|
options = str.slice(vcs.length + 1 + method.length + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (!method) {
|
if (!method) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -28314,7 +28325,10 @@ DisabledMap.prototype.getInstantCommands = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
_.each(this.disabledMap, function(val, disabledCommand) {
|
_.each(this.disabledMap, function(val, disabledCommand) {
|
||||||
var gitRegex = GitCommands.commands.getRegexMap()[disabledCommand];
|
// XXX get hold of vcs from disabledMap
|
||||||
|
var vcs = 'git';
|
||||||
|
disabledCommand = disabledCommand.slice(vcs.length + 1);
|
||||||
|
var gitRegex = GitCommands.commands.getRegexMap()[vcs][disabledCommand];
|
||||||
if (!gitRegex) {
|
if (!gitRegex) {
|
||||||
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
||||||
' has no regex matching');
|
' has no regex matching');
|
||||||
|
@ -29513,10 +29527,14 @@ var getAllCommands = function() {
|
||||||
|
|
||||||
var allCommands = _.extend(
|
var allCommands = _.extend(
|
||||||
{},
|
{},
|
||||||
GitCommands.commands.getRegexMap(),
|
|
||||||
require('../level').regexMap,
|
require('../level').regexMap,
|
||||||
regexMap
|
regexMap
|
||||||
);
|
);
|
||||||
|
_.each(GitCommands.commands.getRegexMap(), function(map, vcs) {
|
||||||
|
_.each(map, function(regex, method) {
|
||||||
|
allCommands[vcs + ' ' + method] = regex;
|
||||||
|
});
|
||||||
|
});
|
||||||
_.each(toDelete, function(key) {
|
_.each(toDelete, function(key) {
|
||||||
delete allCommands[key];
|
delete allCommands[key];
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,10 +50,10 @@ var commands = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getRegexMap: function() {
|
getRegexMap: function() {
|
||||||
var map = {};
|
var map = {'git': {}};
|
||||||
this.loop(function(config, name) {
|
this.loop(function(config, name, vcs) {
|
||||||
var displayName = 'git ' + (config.displayName || name);
|
var displayName = config.displayName || name;
|
||||||
map[displayName] = config.regex;
|
map[vcs][displayName] = config.regex;
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
|
@ -560,13 +560,15 @@ var parse = function(str) {
|
||||||
var options;
|
var options;
|
||||||
|
|
||||||
// see if we support this particular command
|
// see if we support this particular command
|
||||||
_.each(commands.getRegexMap(), function(regex, thisMethod) {
|
_.each(commands.getRegexMap(), function (map, thisVCS) {
|
||||||
|
_.each(map, function(regex, thisMethod) {
|
||||||
if (regex.exec(str)) {
|
if (regex.exec(str)) {
|
||||||
vcs = 'git'; // XXX get from regex map
|
vcs = thisVCS; // XXX get from regex map
|
||||||
options = str.slice(thisMethod.length + 1);
|
method = thisMethod;
|
||||||
method = thisMethod.slice(vcs.length + 1);
|
options = str.slice(vcs.length + 1 + method.length + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (!method) {
|
if (!method) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,7 +26,10 @@ DisabledMap.prototype.getInstantCommands = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
_.each(this.disabledMap, function(val, disabledCommand) {
|
_.each(this.disabledMap, function(val, disabledCommand) {
|
||||||
var gitRegex = GitCommands.commands.getRegexMap()[disabledCommand];
|
// XXX get hold of vcs from disabledMap
|
||||||
|
var vcs = 'git';
|
||||||
|
disabledCommand = disabledCommand.slice(vcs.length + 1);
|
||||||
|
var gitRegex = GitCommands.commands.getRegexMap()[vcs][disabledCommand];
|
||||||
if (!gitRegex) {
|
if (!gitRegex) {
|
||||||
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
throw new Error('wuttttt this disbaled command' + disabledCommand +
|
||||||
' has no regex matching');
|
' has no regex matching');
|
||||||
|
|
|
@ -121,10 +121,14 @@ var getAllCommands = function() {
|
||||||
|
|
||||||
var allCommands = _.extend(
|
var allCommands = _.extend(
|
||||||
{},
|
{},
|
||||||
GitCommands.commands.getRegexMap(),
|
|
||||||
require('../level').regexMap,
|
require('../level').regexMap,
|
||||||
regexMap
|
regexMap
|
||||||
);
|
);
|
||||||
|
_.each(GitCommands.commands.getRegexMap(), function(map, vcs) {
|
||||||
|
_.each(map, function(regex, method) {
|
||||||
|
allCommands[vcs + ' ' + method] = regex;
|
||||||
|
});
|
||||||
|
});
|
||||||
_.each(toDelete, function(key) {
|
_.each(toDelete, function(key) {
|
||||||
delete allCommands[key];
|
delete allCommands[key];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue