{"record":{"id":"736a0581ba4d33ce","repo":"pcottle/learnGitBranching","slug":"command-disabled","errorCode":null,"errorMessage":"command-disabled","messagePattern":"command-disabled","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"warning","filePath":"src/js/level/disabledMap.js","lineNumber":22,"sourceCode":"\nvar Errors = require('../util/errors');\nvar GitError = Errors.GitError;\n\nfunction DisabledMap(options) {\n  options = options || {};\n  this.disabledMap = options.disabledMap || {\n    'git cherry-pick': true,\n    'git rebase': true\n  };\n}\n\nDisabledMap.prototype.getInstantCommands = function() {\n  // this produces an array of regex / function pairs that can be\n  // piped into a parse waterfall to disable certain git commands\n  // :D\n  var instants = [];\n  var onMatch = function() {\n    throw new GitError({\n      msg: intl.str('command-disabled')\n    });\n  };\n\n  Object.keys(this.disabledMap).forEach(function(disabledCommand) {\n    // XXX get hold of vcs from disabledMap\n    var vcs = 'git';\n    disabledCommand = disabledCommand.slice(vcs.length + 1);\n    var gitRegex = Commands.commands.getRegexMap()[vcs][disabledCommand];\n    if (!gitRegex) {\n      throw new Error('wuttttt this disbaled command' + disabledCommand +\n        ' has no regex matching');\n    }\n    instants.push([gitRegex, onMatch]);\n  }.bind(this));\n  return instants;\n};\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/level/disabledMap.js#L4-L40","documentation":"Thrown by DisabledMap.getInstantCommands' onMatch closure when a command the current level has disabled matches the user's input. Levels can blacklist commands (to force alternative solutions), and any match immediately throws GitError with the localized 'command-disabled' message instead of executing.","triggerScenarios":"Typing a command listed in the level's disabledMap (e.g. 'commit' in a level that bans committing) — the generated instant regexes intercept it during the parse waterfall.","commonSituations":"Levels that teach rebasing by disabling cherry-pick, or merging by disabling merge; users attempting shortcuts the level forbids.","solutions":["Use a different, non-disabled command to achieve the level goal","Re-read the level instructions for which commands are restricted","If you genuinely need the command (sandbox mode), exit the level or switch to a level/mode without that disable entry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var banned = levelDisabledMap.disabledMap || {};\nvar firstWord = input.trim().split(/\\s+/)[0];\nif (banned[firstWord]) { /* warn user instead of dispatching */ }","typeGuard":null,"tryCatchPattern":"try { dispatch(input); } catch (e) { if (e instanceof GitError && e.msg === intl.str('command-disabled')) { /* suggest alternative command */ } else throw e; }","preventionTips":["Inspect the level's disabledMap before attempting commands","Read level instructions for banned commands"],"tags":["level","disabled-command","git","sandbox-restriction"],"backgroundTag":"command-disabled-by-config","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}