From d27e28b1095016fede401ae21af6e18b6ac1144f Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Tue, 5 Nov 2013 09:13:16 -0800 Subject: [PATCH] describe level Resolves #144 Wooooo --- src/js/git/index.js | 2 +- src/levels/index.js | 3 +- src/levels/mixed/describe.js | 76 ++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 src/levels/mixed/describe.js diff --git a/src/js/git/index.js b/src/js/git/index.js index 67ac7c16..c7bf862f 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -2421,7 +2421,7 @@ GitEngine.prototype.describe = function(ref) { // then join throw new CommandResult({ - msg: foundTag + '_' + numAway.length + '_g' + numAway.pop() + msg: foundTag + '_' + numAway.length + '_g' + startCommit.get('id') }); }; diff --git a/src/levels/index.js b/src/levels/index.js index ce241679..8d7df70a 100644 --- a/src/levels/index.js +++ b/src/levels/index.js @@ -21,7 +21,8 @@ exports.levelSequences = { require('./mixed/grabbingOneCommit').level, require('./mixed/jugglingCommits').level, require('./mixed/jugglingCommits2').level, - require('./mixed/tags').level + require('./mixed/tags').level, + require('./mixed/describe').level ], advanced: [ require('./rebase/manyRebases').level, diff --git a/src/levels/mixed/describe.js b/src/levels/mixed/describe.js new file mode 100644 index 00000000..efa31b61 --- /dev/null +++ b/src/levels/mixed/describe.js @@ -0,0 +1,76 @@ +exports.level = { + "goalTreeString": "{\"branches\":{\"master\":{\"target\":\"C2\",\"id\":\"master\",\"remoteTrackingBranchID\":null},\"side\":{\"target\":\"C4\",\"id\":\"side\",\"remoteTrackingBranchID\":null},\"bugFix\":{\"target\":\"C7\",\"id\":\"bugFix\",\"remoteTrackingBranchID\":null}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"},\"C2\":{\"parents\":[\"C1\"],\"id\":\"C2\"},\"C3\":{\"parents\":[\"C1\"],\"id\":\"C3\"},\"C4\":{\"parents\":[\"C3\"],\"id\":\"C4\"},\"C5\":{\"parents\":[\"C3\"],\"id\":\"C5\"},\"C6\":{\"parents\":[\"C5\"],\"id\":\"C6\"},\"C7\":{\"parents\":[\"C6\"],\"id\":\"C7\"}},\"tags\":{\"v0\":{\"target\":\"C0\",\"id\":\"v0\",\"type\":\"tag\"},\"v1\":{\"target\":\"C3\",\"id\":\"v1\",\"type\":\"tag\"}},\"HEAD\":{\"target\":\"bugFix\",\"id\":\"HEAD\"}}", + "solutionCommand": "git commit ", + "startTree": "{\"branches\":{\"master\":{\"target\":\"C2\",\"id\":\"master\",\"remoteTrackingBranchID\":null},\"side\":{\"target\":\"C4\",\"id\":\"side\",\"remoteTrackingBranchID\":null},\"bugFix\":{\"target\":\"C6\",\"id\":\"bugFix\",\"remoteTrackingBranchID\":null}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"},\"C2\":{\"parents\":[\"C1\"],\"id\":\"C2\"},\"C3\":{\"parents\":[\"C1\"],\"id\":\"C3\"},\"C4\":{\"parents\":[\"C3\"],\"id\":\"C4\"},\"C5\":{\"parents\":[\"C3\"],\"id\":\"C5\"},\"C6\":{\"parents\":[\"C5\"],\"id\":\"C6\"}},\"tags\":{\"v0\":{\"target\":\"C0\",\"id\":\"v0\",\"type\":\"tag\"},\"v1\":{\"target\":\"C3\",\"id\":\"v1\",\"type\":\"tag\"}},\"HEAD\":{\"target\":\"bugFix\",\"id\":\"HEAD\"}}", + "name": { + "en_US": "Git Describe" + }, + "hint": { + "en_US": "Just commit once on bugFix when you're ready to move on" + }, + "startDialog": { + "en_US": { + "childViews": [ + { + "type": "ModalAlert", + "options": { + "markdowns": [ + "### Git Describe", + "", + "Because tags serve as such great \"anchors\" in the codebase, git has a command to *describe* where you are relative to the closest "anchor" (aka tag). And that command is called `git describe`!", + "", + "Git describe can help you get your bearings after you've moved many commits backwards or forwards in history; this can happen after you've completed a git bisect (a debugging search) or when sitting down at a coworkers computer who just got back from vacation." + ] + } + }, + { + "type": "ModalAlert", + "options": { + "markdowns": [ + "Git describe takes the form of:", + "", + "`git describe `", + "", + "Where `` is anything git can resolve into a commit. If you don't specify a ref, git just uses where you're checked out right now (`HEAD`).", + "", + "The output of the command looks like:", + "", + "`__g`", + "", + "Where `tag` is the closest ancestor tag in history, `numCommits` is how many commits away that tag is, and `` is the hash of the commit being described." + ] + } + }, + { + "type": "GitDemonstrationView", + "options": { + "beforeMarkdowns": [ + "Let's look at a quick example. For this tree below:" + ], + "afterMarkdowns": [ + "The command `git describe master` would output:", + "", + "`v1_2_gC2`", + "", + "Whereas `git describe side` would output:", + "", + "`v2_1_gC4`" + ], + "command": "git tag v2 C3", + "beforeCommand": "git commit; go -b side HEAD~1; gc; gc; git tag v1 C0" + } + }, + { + "type": "ModalAlert", + "options": { + "markdowns": [ + "That's pretty much all there is to git describe! Try describing a few of the locations in this level to get a feel for the command.", + "", + "Once you're ready, just go ahead and commit once to finish the level. We're giving you a freebie :P" + ] + } + } + ] + } + } +};