mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
better command counting
This commit is contained in:
parent
f4179e9723
commit
76b8a6cc9d
3 changed files with 93 additions and 6 deletions
|
@ -25,6 +25,7 @@ var Level = Sandbox.extend({
|
|||
options.level = options.level || {};
|
||||
|
||||
this.gitCommandsIssued = 0;
|
||||
this.commandsThatCount = this.getCommandsThatCount();
|
||||
this.solved = false;
|
||||
|
||||
// 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) {
|
||||
// TODO check if error, but not warning
|
||||
this.gitCommandsIssued++;
|
||||
var matched = false;
|
||||
_.each(this.commandsThatCount, function(regex) {
|
||||
matched = matched || regex.test(command.get('rawStr'));
|
||||
});
|
||||
if (matched) {
|
||||
this.gitCommandsIssued++;
|
||||
}
|
||||
console.log('git commands isssued', this.gitCommandsIssued);
|
||||
},
|
||||
|
||||
afterCommandDefer: function(defer) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue