From 803f4f897aeffa11b67522f1a9459e4315b5d43e Mon Sep 17 00:00:00 2001 From: blinry Date: Fri, 13 Nov 2020 12:27:15 +0100 Subject: [PATCH] "branch-remove" level --- levels/time-machine/branch-remove | 47 +++++++++++++++++++++++++++++++ resources/cards.json | 5 ++++ scenes/card.gd | 2 +- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 levels/time-machine/branch-remove diff --git a/levels/time-machine/branch-remove b/levels/time-machine/branch-remove new file mode 100644 index 0000000..9d91108 --- /dev/null +++ b/levels/time-machine/branch-remove @@ -0,0 +1,47 @@ +title = Choose your own adventure +cards = checkout commit-auto reset-hard branch-delete + +[description] + +Life is full of dangers, right? Even when walking to school, it seems like there's a lot of risks! + +This Monday is especially bad. You made it to school, but there's some timelines you definitely don't want to keep around. + +Find the bad branches and delete them. Keep the one that seems okay. + +[setup] + +echo You leave your house and start walking to school. > you +git add . +git commit -m "Good morning!" + +echo You walk on the right side of the street. >> you +git commit -am "Right side" + +echo You jump over an manhole in the walkway, and arrive at school on time. >> you +git commit -am "Jump" + +git checkout HEAD^ -b friend +echo Suddenly, you fall down, splash into stinking water, and are eaten by an alligator. >> you +git commit -am "A new friend" + +git checkout HEAD~2 -b music +echo You walk on the left side of the street. >> you +git commit -am "Left side" + +echo Because you\'re kind of late, you start running. Someone throws a piano out of their windows, and it smashes you. >> you +git commit -am "Sounds nice" + +git checkout HEAD^ -b ice-cream +echo You\'re not in a hurry, and walk slowly. You even get some ice cream on your way. You arrive at school too late, and your teacher is angry. >> you +git commit -am "Yum" + +git checkout main + +[win] + +test "$(git branch | cut -c 3-)" = "$(echo -e ice-cream\\nmain)" + +[congrats] + +On second thought, maybe you even prefer the ice cream timeline to the main one? :) diff --git a/resources/cards.json b/resources/cards.json index 8ce33a7..c865647 100644 --- a/resources/cards.json +++ b/resources/cards.json @@ -94,6 +94,11 @@ "command": "git branch [string]", "description": "Create a new branch." }, + { + "id": "branch-delete", + "command": "git branch -D [ref]", + "description": "Delete a branch." + }, { "id": "file-new", "command": "touch [string]", diff --git a/scenes/card.gd b/scenes/card.gd index 3738bff..56979f2 100644 --- a/scenes/card.gd +++ b/scenes/card.gd @@ -123,7 +123,7 @@ func dropped_on(other): else: argument = other.id - if (command.begins_with("git checkout") or command.begins_with("git rebase")) and argument.begins_with("refs/heads"): + if (command.begins_with("git checkout") or command.begins_with("git rebase") or command.begins_with("git branch -D")) and argument.begins_with("refs/heads"): argument = Array(argument.split("/")).pop_back() var arg_regex = RegEx.new()