From e754671b88655f883e69187059f6bee4572d8404 Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 5 Jan 2021 12:46:07 +0100 Subject: [PATCH 1/4] First version of an "index" chapter --- levels/index/add | 21 +++++++++++++++++++++ levels/index/checkout | 21 +++++++++++++++++++++ levels/index/commit | 27 +++++++++++++++++++++++++++ levels/index/commit-a | 26 ++++++++++++++++++++++++++ levels/index/mv | 26 ++++++++++++++++++++++++++ levels/index/new | 19 +++++++++++++++++++ levels/index/reset | 22 ++++++++++++++++++++++ levels/index/rm | 24 ++++++++++++++++++++++++ levels/index/sequence | 8 ++++++++ levels/sequence | 1 + resources/cards.json | 23 +++++++++++++++++++---- scenes/title.tscn | 4 ++-- 12 files changed, 216 insertions(+), 6 deletions(-) create mode 100644 levels/index/add create mode 100644 levels/index/checkout create mode 100644 levels/index/commit create mode 100644 levels/index/commit-a create mode 100644 levels/index/mv create mode 100644 levels/index/new create mode 100644 levels/index/reset create mode 100644 levels/index/rm create mode 100644 levels/index/sequence diff --git a/levels/index/add b/levels/index/add new file mode 100644 index 0000000..ddbc61a --- /dev/null +++ b/levels/index/add @@ -0,0 +1,21 @@ +title = Updating files in the index +cards = add + +[description] + +So you start working, and make changes to your files! Git lets you choose which of these changes you want to put in the next commit. This is like updating the index version of that file to the new version. + +The command for this is the same - `git add`! + +[setup] + +echo a > a +echo b > b +echo c > c +git add . +git commit -m "Initial commit" + +[win] + +# Make changes to all three files, and add all of them to the index. +test "$(git diff --cached --name-only | wc -l)" -eq 3 diff --git a/levels/index/checkout b/levels/index/checkout new file mode 100644 index 0000000..491fc32 --- /dev/null +++ b/levels/index/checkout @@ -0,0 +1,21 @@ +title = Checking out files from the index +cards = add reset checkout + +[description] + +So you've made changes to your files, but you decide that you don't want to keep them! You can use `git checkout` for that! + +[setup] + +echo a > a +echo b > b +echo c > c +git add . +git commit -m "Initial commit" +echo x > a +echo x > b + +[win] + +# Remove all changes in your local files! +test "$(git diff --name-only | wc -l)" -eq 0 diff --git a/levels/index/commit b/levels/index/commit new file mode 100644 index 0000000..7d3071b --- /dev/null +++ b/levels/index/commit @@ -0,0 +1,27 @@ +title = Make a commit \o/ +cards = add reset checkout commit + +[description] + +With that, we're ready to make our first commit! It will contain the version of the files which are currently in the index. + +[setup] + +echo a > a +echo x > b +echo x > c +git add . +git commit -m "Initial commit" +echo x > a +echo b > b +git add b +echo c > c + +[win] + +# File a contains "x" in the last main commit. +test "$(git show main:a)" = x +# File b contains "x" in the last main commit. +test "$(git show main:b)" = x +# File c contains "x" in the last main commit. +test "$(git show main:c)" = x diff --git a/levels/index/commit-a b/levels/index/commit-a new file mode 100644 index 0000000..747a009 --- /dev/null +++ b/levels/index/commit-a @@ -0,0 +1,26 @@ +title = Make a commit, but faster! +cards = add reset checkout commit commit-a + +[description] + +There is a time-saving trick, where instead of a plain `git commit`, you can use + + git commit -a + +This will automatically add all changes you made to local files! Very convenient. + +[setup] + +echo a > a +echo b > b +echo c > c +git add . +git commit -m "Initial commit" +echo x > a +echo x > b +echo x > c + +[win] + +# Make a commit where all files contain "x". +test "$(git show main:a)" = x && test "$(git show main:b)" = x && test "$(git show main:c)" = x diff --git a/levels/index/mv b/levels/index/mv new file mode 100644 index 0000000..53c2da1 --- /dev/null +++ b/levels/index/mv @@ -0,0 +1,26 @@ +title = Rename a file in the next commit +cards = add reset checkout mv commit + +[description] + +Other times, you might want to rename a file in the next commit. Use + + git mv [file] [new name] + +for that. The effect is very similar as if you had created a copy with a new name, and removed the old version. + +[setup] + +echo a > a +echo SPECIAL > b +echo x > c +git add . +git commit -m "Initial commit" +echo x > a +echo b >> b +git add b + +[win] + +# Make a commit where you rename the file b to "x". +test "$(git ls-tree --name-only main)" = "$(echo -e "a\nc\nx")" diff --git a/levels/index/new b/levels/index/new new file mode 100644 index 0000000..b46898b --- /dev/null +++ b/levels/index/new @@ -0,0 +1,19 @@ +title = Add new files to the index +cards = add + +[description] + +In the index, we can prepare what will be in the next commit. + +Initially, the index will be empty, and all files are untracked. If you have a file, and you want to have it in the next commit, use `git add`! + +[setup] + +echo a > a +echo b > b +echo c > c + +[win] + +# Add all three files to the index. +test "$(git diff --cached --name-only | wc -l)" -eq 3 diff --git a/levels/index/reset b/levels/index/reset new file mode 100644 index 0000000..9baf28b --- /dev/null +++ b/levels/index/reset @@ -0,0 +1,22 @@ +title = Resetting files in the index +cards = add reset + +[description] + +If you already have changes in the index, but want to reset them, you can use `git reset`! + +[setup] + +echo a > a +echo b > b +echo c > c +git add . +git commit -m "Initial commit" +echo x > a +echo x > b +git add . + +[win] + +# Reset all changes in files in the index! +test "$(git diff --cached --name-only | wc -l)" -eq 0 diff --git a/levels/index/rm b/levels/index/rm new file mode 100644 index 0000000..df769f3 --- /dev/null +++ b/levels/index/rm @@ -0,0 +1,24 @@ +title = Delete a file in the next commit +cards = add reset checkout rm commit + +[description] + +If you want to remove a file in the next commit, you can use `git rm`! This will both delete the file locally, and in the index. + +If a file is modified, you'll need to reset these changes first/reset the files. + +[setup] + +echo a > a +echo x > b +echo x > c +git add . +git commit -m "Initial commit" +echo x > a +echo b > b +git add b + +[win] + +# Make a commit where all files are deleted ¯\_(^_^)_/¯ +test "$(git ls-tree main | wc -l)" -eq 0 diff --git a/levels/index/sequence b/levels/index/sequence new file mode 100644 index 0000000..7a4987c --- /dev/null +++ b/levels/index/sequence @@ -0,0 +1,8 @@ +new +add +reset +checkout +commit +commit-a +rm +mv diff --git a/levels/sequence b/levels/sequence index f159582..49acab7 100644 --- a/levels/sequence +++ b/levels/sequence @@ -1,2 +1,3 @@ +index time-machine low-level diff --git a/resources/cards.json b/resources/cards.json index c865647..f86aed1 100644 --- a/resources/cards.json +++ b/resources/cards.json @@ -6,8 +6,13 @@ }, { "id": "checkout", - "command": "git checkout [commit, ref]", - "description": "Drag this card to a commit or to a branch to travel to it!" + "command": "git checkout [commit, ref, file]", + "description": "Drag this card to a commit or to a branch to travel to it!\n\nAlternatively, reset changes in a local file." + }, + { + "id": "commit-a", + "command": "git commit -a", + "description": "Make a new commit, after automatically adding all changes to the index.\nYou'll be asked to enter a short description of what you changed." }, { "id": "commit-auto", @@ -51,8 +56,8 @@ }, { "id": "reset", - "command": "git reset [commit]", - "description": "Jump to the commit, and update the index. Keep the current environment." + "command": "git reset [commit, file]", + "description": "Jump to the commit, and update the index. Keep the current environment.\n\nAlternatively, reset changes in a file in the index." }, { "id": "cherry-pick", @@ -79,6 +84,16 @@ "command": "git add [file]", "description": "Put the current status of the file into the plan." }, + { + "id": "rm", + "command": "git rm [file]", + "description": "Delete a file both in the working directory, as well as the index." + }, + { + "id": "mv", + "command": "git mv [file] [string]", + "description": "DOESN'T WORK YET\n\nRename a file both in the working directory, as well as the index." + }, { "id": "commit", "command": "git commit", diff --git a/scenes/title.tscn b/scenes/title.tscn index 98c8a01..05b21a8 100644 --- a/scenes/title.tscn +++ b/scenes/title.tscn @@ -61,13 +61,13 @@ __meta__ = { } [node name="Button" type="Button" parent="VBoxContainer"] -margin_right = 352.0 +margin_right = 351.0 margin_bottom = 39.0 text = "Levels" [node name="Button2" type="Button" parent="VBoxContainer"] margin_top = 44.0 -margin_right = 352.0 +margin_right = 351.0 margin_bottom = 83.0 text = "Quit" [connection signal="pressed" from="VBoxContainer/Button" to="." method="levels"] From 7c96367d726e65c4232a6371e86d674187743fff Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 5 Jan 2021 13:05:46 +0100 Subject: [PATCH 2/4] Reload levels when entering the level select, and show titles in levels --- scenes/level_select.gd | 2 ++ scenes/main.tscn | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scenes/level_select.gd b/scenes/level_select.gd index 84db1a0..0dbb66d 100644 --- a/scenes/level_select.gd +++ b/scenes/level_select.gd @@ -5,6 +5,8 @@ onready var level_list = $ScrollContainer/MarginContainer/Levels func _ready(): var chapter_id = 0 + levels.reload() + for chapter in levels.chapters: var level_id = 0 diff --git a/scenes/main.tscn b/scenes/main.tscn index 655f71b..2a5cdb0 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -175,7 +175,6 @@ margin_bottom = 383.0 size_flags_vertical = 3 [node name="LevelName" type="RichTextLabel" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"] -visible = false margin_right = 633.0 margin_bottom = 60.0 rect_min_size = Vector2( 0, 60 ) @@ -186,6 +185,7 @@ __meta__ = { } [node name="Text" type="Control" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"] +margin_top = 65.0 margin_right = 633.0 margin_bottom = 336.0 size_flags_vertical = 3 From 00ec6f6700f89d44d9892f9c4d51336635fb6066 Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 5 Jan 2021 13:08:43 +0100 Subject: [PATCH 3/4] Reload card store when reloading a level --- scenes/cards.gd | 1 + scenes/main.gd | 1 + 2 files changed, 2 insertions(+) diff --git a/scenes/cards.gd b/scenes/cards.gd index c9273be..f960431 100644 --- a/scenes/cards.gd +++ b/scenes/cards.gd @@ -15,6 +15,7 @@ func _process(_delta): $Energy.text = str(game.energy) func load_card_store(): + card_store = {} var cards_json = JSON.parse(helpers.read_file("res://resources/cards.json")).result for card in cards_json: card_store[card["id"]] = card diff --git a/scenes/main.gd b/scenes/main.gd index 75ea368..3dda941 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -121,6 +121,7 @@ func load_level(level_id): func reload_level(): + cards.load_card_store() levels.reload() load_level(game.current_level) From 77a5b9f9e7a93a6f9b563aad44b2544e752b5f68 Mon Sep 17 00:00:00 2001 From: blinry Date: Tue, 5 Jan 2021 13:12:21 +0100 Subject: [PATCH 4/4] Only trigger GitHub deploy workflow on tags We're doing a lot of half-baked prototyping in between. :D --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 295ee92..afc6a1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,8 +2,8 @@ name: "Build" on: push: - branches: - - main + tags: + - '*' env: PROJECT_NAME: ${{ github.event.repository.name }}