From 617adc8e06cddf7dde9790dace802f5c5eb339bf Mon Sep 17 00:00:00 2001 From: blinry Date: Thu, 29 Oct 2020 17:23:12 +0100 Subject: [PATCH] Build custom .gitconfig for the game environment Fixes #3. --- scenes/game.gd | 2 ++ scenes/level.gd | 1 - scenes/node.gd | 1 - scenes/shell.gd | 8 +------- scripts/gitconfig | 12 ++++++++++++ 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 scripts/gitconfig diff --git a/scenes/game.gd b/scenes/game.gd index 5cca835..5157148 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -13,6 +13,8 @@ var state = {} func _ready(): global_shell = Shell.new() + create_file_in_game_env(".gitconfig", helpers.read_file("res://scripts/gitconfig")) + create_file_in_game_env("fake-editor", helpers.read_file("res://scripts/fake-editor")) fake_editor = tmp_prefix + "fake-editor" global_shell.run("chmod u+x '%s'" % fake_editor) diff --git a/scenes/level.gd b/scenes/level.gd index 07eb91e..1c53806 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -83,7 +83,6 @@ func construct(): game.global_shell.run("mkdir '%s'" % repo.path) game.global_shell.cd(repo.path) game.global_shell.run("git init") - game.global_shell.run("git symbolic-ref HEAD refs/heads/main") # Add other repos as remotes. for r2 in repos: diff --git a/scenes/node.gd b/scenes/node.gd index 9c1e9bc..c782412 100644 --- a/scenes/node.gd +++ b/scenes/node.gd @@ -100,7 +100,6 @@ func children_set(new_children): if not children.has(c): var a = arrow.instance() if type == "commit": - #a = time_arrow.instance() a.source = c a.target = id a.color = Color("c2bf26") diff --git a/scenes/shell.gd b/scenes/shell.gd index 7a9a308..be1cc53 100644 --- a/scenes/shell.gd +++ b/scenes/shell.gd @@ -24,13 +24,7 @@ func run(command, crash_on_fail=true): print("$ %s" % command) var env = {} - if game.fake_editor: - env["GIT_EDITOR"] = game.fake_editor.replace(" ", "\\ ") - env["GIT_AUTHOR_NAME"] = "You" - env["GIT_COMMITTER_NAME"] = "You" - env["GIT_AUTHOR_EMAIL"] = "you@example.com" - env["GIT_COMMITTER_EMAIL"] = "you@example.com" - env["GIT_TEMPLATE_DIR"] = "" + env["HOME"] = game.tmp_prefix var hacky_command = "" for variable in env: diff --git a/scripts/gitconfig b/scripts/gitconfig new file mode 100644 index 0000000..3a6e394 --- /dev/null +++ b/scripts/gitconfig @@ -0,0 +1,12 @@ +[user] + email = you@time.agency + name = You +[core] + editor = ~/fake-editor +[init] + templateDir = "" + defaultBranch = main +[log] + decorate = true +[advice] + detachedHead = false