better command counting

This commit is contained in:
Peter Cottle 2013-01-03 17:47:30 -08:00
parent f4179e9723
commit 76b8a6cc9d
3 changed files with 93 additions and 6 deletions

View file

@ -4758,6 +4758,7 @@ var Level = Sandbox.extend({
options.level = options.level || {}; options.level = options.level || {};
this.gitCommandsIssued = 0; this.gitCommandsIssued = 0;
this.commandsThatCount = this.getCommandsThatCount();
this.solved = false; this.solved = false;
// possible options on how stringent to be on comparisons go here // possible options on how stringent to be on comparisons go here
@ -4805,9 +4806,36 @@ var Level = Sandbox.extend({
}); });
}, },
getCommandsThatCount: function() {
var GitCommands = require('../git/commands');
var toCount = [
'git commit',
'git checkout',
'git rebase',
'git reset',
'git branch',
'git revert',
'git merge',
'git cherry-pick'
];
var myRegexMap = {};
_.each(toCount, function(method) {
if (!GitCommands.regexMap[method]) { throw new Error('wut no regex'); }
myRegexMap[method] = GitCommands.regexMap[method];
});
return myRegexMap;
},
afterCommandCB: function(command) { afterCommandCB: function(command) {
// TODO check if error, but not warning var matched = false;
_.each(this.commandsThatCount, function(regex) {
matched = matched || regex.test(command.get('rawStr'));
});
if (matched) {
this.gitCommandsIssued++; this.gitCommandsIssued++;
}
console.log('git commands isssued', this.gitCommandsIssued);
}, },
afterCommandDefer: function(defer) { afterCommandDefer: function(defer) {
@ -11894,6 +11922,7 @@ exports.instantCommands = instantCommands;
exports.parse = parse; exports.parse = parse;
exports.regexMap = regexMap; exports.regexMap = regexMap;
}); });
require.define("/src/js/level/parseWaterfall.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); require.define("/src/js/level/parseWaterfall.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
@ -15232,6 +15261,7 @@ exports.instantCommands = instantCommands;
exports.parse = parse; exports.parse = parse;
exports.regexMap = regexMap; exports.regexMap = regexMap;
}); });
require("/src/js/git/commands.js"); require("/src/js/git/commands.js");
@ -17255,6 +17285,7 @@ var Level = Sandbox.extend({
options.level = options.level || {}; options.level = options.level || {};
this.gitCommandsIssued = 0; this.gitCommandsIssued = 0;
this.commandsThatCount = this.getCommandsThatCount();
this.solved = false; this.solved = false;
// possible options on how stringent to be on comparisons go here // possible options on how stringent to be on comparisons go here
@ -17302,9 +17333,36 @@ var Level = Sandbox.extend({
}); });
}, },
getCommandsThatCount: function() {
var GitCommands = require('../git/commands');
var toCount = [
'git commit',
'git checkout',
'git rebase',
'git reset',
'git branch',
'git revert',
'git merge',
'git cherry-pick'
];
var myRegexMap = {};
_.each(toCount, function(method) {
if (!GitCommands.regexMap[method]) { throw new Error('wut no regex'); }
myRegexMap[method] = GitCommands.regexMap[method];
});
return myRegexMap;
},
afterCommandCB: function(command) { afterCommandCB: function(command) {
// TODO check if error, but not warning var matched = false;
_.each(this.commandsThatCount, function(regex) {
matched = matched || regex.test(command.get('rawStr'));
});
if (matched) {
this.gitCommandsIssued++; this.gitCommandsIssued++;
}
console.log('git commands isssued', this.gitCommandsIssued);
}, },
afterCommandDefer: function(defer) { afterCommandDefer: function(defer) {

View file

@ -185,3 +185,4 @@ exports.shortcutMap = shortcutMap;
exports.instantCommands = instantCommands; exports.instantCommands = instantCommands;
exports.parse = parse; exports.parse = parse;
exports.regexMap = regexMap; exports.regexMap = regexMap;

View file

@ -25,6 +25,7 @@ var Level = Sandbox.extend({
options.level = options.level || {}; options.level = options.level || {};
this.gitCommandsIssued = 0; this.gitCommandsIssued = 0;
this.commandsThatCount = this.getCommandsThatCount();
this.solved = false; this.solved = false;
// possible options on how stringent to be on comparisons go here // possible options on how stringent to be on comparisons go here
@ -72,9 +73,36 @@ var Level = Sandbox.extend({
}); });
}, },
getCommandsThatCount: function() {
var GitCommands = require('../git/commands');
var toCount = [
'git commit',
'git checkout',
'git rebase',
'git reset',
'git branch',
'git revert',
'git merge',
'git cherry-pick'
];
var myRegexMap = {};
_.each(toCount, function(method) {
if (!GitCommands.regexMap[method]) { throw new Error('wut no regex'); }
myRegexMap[method] = GitCommands.regexMap[method];
});
return myRegexMap;
},
afterCommandCB: function(command) { afterCommandCB: function(command) {
// TODO check if error, but not warning var matched = false;
_.each(this.commandsThatCount, function(regex) {
matched = matched || regex.test(command.get('rawStr'));
});
if (matched) {
this.gitCommandsIssued++; this.gitCommandsIssued++;
}
console.log('git commands isssued', this.gitCommandsIssued);
}, },
afterCommandDefer: function(defer) { afterCommandDefer: function(defer) {