From 8760ad717879068e7e8cc59ac628376ddaab7053 Mon Sep 17 00:00:00 2001 From: blinry Date: Mon, 9 Nov 2020 20:45:39 +0100 Subject: [PATCH] Enable files' drop area, two levels about the index --- levels/time-machine/sequence | 5 ++++- levels/time-machine/split | 26 ++++++++++++++++++++++++++ levels/time-machine/steps | 23 +++++++++++++++++++++++ resources/cards.json | 22 +++++++++++++++++++++- scenes/file_browser_item.tscn | 6 +++++- scenes/level.gd | 4 +++- scenes/main.gd | 5 ++++- scenes/main.tscn | 2 +- 8 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 levels/time-machine/split create mode 100644 levels/time-machine/steps diff --git a/levels/time-machine/sequence b/levels/time-machine/sequence index 4c5c31f..4e85a99 100644 --- a/levels/time-machine/sequence +++ b/levels/time-machine/sequence @@ -1,10 +1,13 @@ -conflict init checkout-commit branching merge branches +conflict pull-push rebase reorder bisect +steps +split +sandbox diff --git a/levels/time-machine/split b/levels/time-machine/split new file mode 100644 index 0000000..274b792 --- /dev/null +++ b/levels/time-machine/split @@ -0,0 +1,26 @@ +title = Split a commit! +cards = checkout commit reset-hard reset add rebase-interactive rebase-continue show + +[description] + +Here, both changes happened in one commit! Split them to be in two commits instead. + +[setup] + +echo something > file1 +echo something else > file2 +git add . +git commit -m "Initial commit" + +echo this should happen first >> file1 +echo and this should happen after that >> file2 +git commit -am "Both together" + +echo this is some other change >> file1 +echo this is some other change >> file2 +git commit -am "Something else" + +[win] + +test "$(git diff-tree --no-commit-id --name-status -r main^)" = "M file2" && +test "$(git diff-tree --no-commit-id --name-status -r main~2)" = "M file1" diff --git a/levels/time-machine/steps b/levels/time-machine/steps new file mode 100644 index 0000000..cb84861 --- /dev/null +++ b/levels/time-machine/steps @@ -0,0 +1,23 @@ +title = One step after another +cards = checkout commit reset-hard add + +[description] + +Sometimes, you might want to record the order in which things changed, instead of making a single commit. + +What happened here? Make two commits from the changes (using the "add" card), in an order that makes sense! + +[setup] + +echo something > file1 +echo something else > file2 +git add . +git commit -m "Initial commit" + +echo this should happen first >> file1 +echo and this should happen after that >> file2 + +[win] + +test "$(git diff-tree --no-commit-id --name-status -r main)" = "M file2" && +test "$(git diff-tree --no-commit-id --name-status -r main^)" = "M file1" diff --git a/resources/cards.json b/resources/cards.json index fae1d75..92b4c41 100644 --- a/resources/cards.json +++ b/resources/cards.json @@ -39,11 +39,21 @@ "command": "git rebase -i [commit]", "description": "Make changes to the events in your current timeline, back to the commit you drag this to." }, + { + "id": "rebase-continue", + "command": "git rebase --continue", + "description": "Continue the current rebasing process." + }, { "id": "reset-hard", "command": "git reset --hard [commit]", "description": "Move the branch you're on to the specified commit." }, + { + "id": "reset", + "command": "git reset [commit]", + "description": "Jump to the commit, and update the index. Keep the current environment." + }, { "id": "cherry-pick", "command": "git cherry-pick [commit]", @@ -67,6 +77,16 @@ { "id": "add", "command": "git add [file]", - "description": "" + "description": "Put the current status of the file into the plan." + }, + { + "id": "commit", + "command": "git commit", + "description": "Make a commit from the plan." + }, + { + "id": "show", + "command": "git show [commit]", + "description": "Show what changed in the commit." } ] diff --git a/scenes/file_browser_item.tscn b/scenes/file_browser_item.tscn index 9272cad..8ebe23c 100644 --- a/scenes/file_browser_item.tscn +++ b/scenes/file_browser_item.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://scenes/file_browser_item.gd" type="Script" id=1] [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2] [ext_resource path="res://nodes/document.svg" type="Texture" id=3] +[ext_resource path="res://scenes/drop_area.tscn" type="PackedScene" id=4] [node name="Control" type="Control"] anchor_right = 0.104 @@ -79,3 +80,6 @@ custom_fonts/font = ExtResource( 2 ) text = "filename" align = 1 autowrap = true + +[node name="DropArea" parent="." instance=ExtResource( 4 )] +position = Vector2( 88.6643, 48.5029 ) diff --git a/scenes/level.gd b/scenes/level.gd index 0a74800..13610c0 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -21,7 +21,9 @@ func load(path): title = config.get("title", slug) description = config.get("description", "(no description)") congrats = config.get("congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next level'.") - cards = Array(config.get("cards", "checkout commit-auto merge rebase rebase-interactive reset-hard cherry-pick add").split(" ")) + cards = Array(config.get("cards", "").split(" ")) + if cards == [""]: + cards = [] var keys = config.keys() var repo_setups = [] diff --git a/scenes/main.gd b/scenes/main.gd index dfb653c..5882b6c 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -65,7 +65,10 @@ func load_level(level_id): level_description.bbcode_text = level.description level_congrats.bbcode_text = level.congrats level_name.text = level.title - cards.draw(levels.chapters[current_chapter].levels[current_level].cards) + if levels.chapters[current_chapter].levels[current_level].cards.size() == 0: + cards.redraw_all_cards() + else: + cards.draw(levels.chapters[current_chapter].levels[current_level].cards) for r in repositories_node.get_children(): r.queue_free() diff --git a/scenes/main.tscn b/scenes/main.tscn index a771d29..f40c7b7 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -197,7 +197,7 @@ margin_right = 633.0 margin_bottom = 582.0 size_flags_vertical = 3 size_flags_stretch_ratio = 0.5 -title = "Next Commit:" +title = "Plan for the next commit" mode = 2 [node name="FileBrowser" parent="Rows/Columns/RightSide" instance=ExtResource( 5 )]