From 023a98cfae7a7495ae7b2c3e0b17e3c2cbf87dc7 Mon Sep 17 00:00:00 2001 From: blinry Date: Thu, 7 Jan 2021 17:35:08 +0100 Subject: [PATCH] config level, clone level, PR level --- levels/intro/clone | 20 ++++++++++++++++++++ levels/intro/who-are-you | 23 +++++++++++++++++++++++ levels/workflows/gitignore | 18 ++++++++++++++++++ levels/workflows/pr | 25 +++++++++++++++++++++++++ resources/cards.json | 15 +++++++++++++++ scenes/card.gd | 2 +- scenes/repository.gd | 3 +++ scenes/repository.tscn | 6 +++++- 8 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 levels/intro/clone create mode 100644 levels/intro/who-are-you create mode 100644 levels/workflows/gitignore create mode 100644 levels/workflows/pr diff --git a/levels/intro/clone b/levels/intro/clone new file mode 100644 index 0000000..8459c08 --- /dev/null +++ b/levels/intro/clone @@ -0,0 +1,20 @@ +title = Cloning a repo +cards = clone commit-auto pull push + +[description] + +Get your friend's repo using clone, change something, push it back. + +[setup] + +rm -rf .git + +[setup friend] + +echo hi > file +git add . +git commit -m "Initial commit" + +[win friend] + +test "$(git show main:file)" != hi diff --git a/levels/intro/who-are-you b/levels/intro/who-are-you new file mode 100644 index 0000000..f06137c --- /dev/null +++ b/levels/intro/who-are-you @@ -0,0 +1,23 @@ +title = Nice to meet you! +cards = config-name config-email + +[description] + +Introduce yourself using + + git config --global user.name Firstname + git config --global user.email "your@mail.com" + +[setup] + +[actions] + +test "$(git config user.name)" != "You" && hint "Hey $(git config user.name), nice to meet you!" + +[win] + +# Have a name configured. +test "$(git config user.name)" != "You" + +# Have an email address configured. +test "$(git config user.email)" != "you@time.agency" diff --git a/levels/workflows/gitignore b/levels/workflows/gitignore new file mode 100644 index 0000000..dc55243 --- /dev/null +++ b/levels/workflows/gitignore @@ -0,0 +1,18 @@ +title = Ignoring files + +[description] + +That chicken is running around a lot, and changing often. We don't want to have it in our commits. + +Add it to the file .gitignore, and try using `git add .`! + +[setup] + +touch .gitignore +echo important > important +git add important +git commit -m "Initial commit" + +[actions] + +echo "$RANDOM" > chicken diff --git a/levels/workflows/pr b/levels/workflows/pr new file mode 100644 index 0000000..1c72510 --- /dev/null +++ b/levels/workflows/pr @@ -0,0 +1,25 @@ +title = Cloning a repo +cards = clone commit-auto reset-hard checkout file-new branch + +[description] + +Your friend has a problem! Clone the repo, create a branch called "solution", and fix the problem in this branch. When you're ready, make a "Pull Request" by using `git tag pr`. + +[setup] + +rm -rf .git + +[setup friend] + +echo "2 + 3 = " > file +git add . +git commit -m "Initial commit" + +[actions friend] + +git ls-remote yours | grep pr && git fetch yours && git merge yours/solution +git show main:file | grep 5 && hint "Thanks!" + +[win friend] + +git show main:file | grep 5 diff --git a/resources/cards.json b/resources/cards.json index d6e38a8..be7ea1f 100644 --- a/resources/cards.json +++ b/resources/cards.json @@ -4,6 +4,21 @@ "command": "git init", "description": "Initialize the time machine!" }, + { + "id": "clone", + "command": "git clone ../[remote] .", + "description": "Create your own copy of your friend's repo." + }, + { + "id": "config-name", + "command": "git config --global user.name [string]", + "description": "Set your name." + }, + { + "id": "config-email", + "command": "git config --global user.email [string]", + "description": "Set your email address." + }, { "id": "checkout", "command": "git checkout [commit, ref]", diff --git a/scenes/card.gd b/scenes/card.gd index 56979f2..90c251f 100644 --- a/scenes/card.gd +++ b/scenes/card.gd @@ -118,7 +118,7 @@ func move_back(): func dropped_on(other): if "[" in command: var argument - if other.type == "file": + if other.type == "file" or other.type == "remote": argument = other.label else: argument = other.id diff --git a/scenes/repository.gd b/scenes/repository.gd index 8222a3b..e1b4f1b 100644 --- a/scenes/repository.gd +++ b/scenes/repository.gd @@ -10,6 +10,8 @@ export var path: String setget set_path, get_path export var simplified_view = true setget set_simplified_view export var editable_path = false setget set_editable_path +var type = "remote" + var node = preload("res://scenes/node.tscn") var shell = Shell.new() @@ -74,6 +76,7 @@ func set_label(new_label): if label_node: if new_label == "yours": new_label = "" + $Rows/RepoVis/DropArea.queue_free() label_node.text = new_label func random_position(): diff --git a/scenes/repository.tscn b/scenes/repository.tscn index 4c7f7bf..dc7a0e9 100644 --- a/scenes/repository.tscn +++ b/scenes/repository.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://scenes/repository.gd" type="Script" id=1] [ext_resource path="res://styles/theme.tres" type="Theme" id=2] [ext_resource path="res://fonts/big.tres" type="DynamicFont" id=3] +[ext_resource path="res://scenes/drop_area.tscn" type="PackedScene" id=4] [node name="Repository" type="Control"] anchor_right = 1.0 @@ -30,6 +31,9 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="DropArea" parent="Rows/RepoVis" instance=ExtResource( 4 )] +position = Vector2( 67.3194, 32.6666 ) + [node name="Label" type="Label" parent="Rows/RepoVis"] margin_left = 5.60091 margin_top = -0.518692