From 75679c8bb1cd78786a93f726f0a0345dba8b9454 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Wed, 9 Sep 2020 18:32:57 +0200 Subject: [PATCH] Use Perl for the fake-editor :D --- game.gd | 2 +- main.gd | 6 ++++-- scripts/fake-editor | 12 ++++++++++-- shell.gd | 4 ++++ terminal.tscn | 18 ++++++++++-------- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/game.gd b/game.gd index dc306d5..eb43aa2 100644 --- a/game.gd +++ b/game.gd @@ -40,7 +40,7 @@ func _tmp_prefix(): elif os == "Windows": # For some reason, this command outputs a space in the end? We remove it. # Also, Godot's default is to use forward slashes for everything. - return exec("echo", ["%TEMP%"]).replacen("\\", "/").replace(" \n", "") + return exec("echo", ["%TEMP%"]).replacen("\\", "/").replace(" \n", "/") else: push_error("Unsupported OS") get_tree().quit() diff --git a/main.gd b/main.gd index b9f1972..2a27e46 100644 --- a/main.gd +++ b/main.gd @@ -101,11 +101,13 @@ func _process(_delta): func read_commit_message(): $CommitMessage.show() input.editable = false - $CommitMessage.text = game.read_file(active_repository.path+"/.git/COMMIT_EDITMSG") + var fixme_path = game.tmp_prefix+"/active" + $CommitMessage.text = game.read_file(fixme_path+"/.git/COMMIT_EDITMSG") $CommitMessage.grab_focus() func save_commit_message(): - game.write_file(active_repository.path+"/.git/COMMIT_EDITMSG", $CommitMessage.text) + var fixme_path = game.tmp_prefix+"/active" + game.write_file(fixme_path+"/.git/COMMIT_EDITMSG", $CommitMessage.text) print("disconnect") client_connection.disconnect_from_host() input.editable = true diff --git a/scripts/fake-editor b/scripts/fake-editor index 326b3f5..f270d81 100755 --- a/scripts/fake-editor +++ b/scripts/fake-editor @@ -1,3 +1,11 @@ -#!/bin/sh +#!/usr/bin/env perl -nc localhost 1234 +use IO::Socket; + +$socket = IO::Socket::INET->new(PeerAddr => "127.0.0.1", + PeerPort => 1234, + Proto => "tcp", + Type => SOCK_STREAM); + +my $reply; +$socket->read($reply, 1000); diff --git a/shell.gd b/shell.gd index 122b760..849cd95 100644 --- a/shell.gd +++ b/shell.gd @@ -21,6 +21,10 @@ func run(command): var env = {} env["EDITOR"] = game.fake_editor + env["GIT_AUTHOR_NAME"] = "You" + env["GIT_COMMITTER_NAME"] = "You" + env["GIT_AUTHOR_EMAIL"] = "you@example.com" + env["GIT_COMMITTER_EMAIL"] = "you@example.com" var hacky_command = "" for variable in env: diff --git a/terminal.tscn b/terminal.tscn index ffc007e..8802e12 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -36,24 +36,26 @@ __meta__ = { [node name="Output" type="RichTextLabel" parent="Control"] margin_right = 1920.0 -margin_bottom = 1039.0 +margin_bottom = 1019.0 size_flags_vertical = 3 custom_styles/normal = SubResource( 1 ) custom_fonts/normal_font = ExtResource( 1 ) scroll_following = true [node name="Button" parent="Control" instance=ExtResource( 4 )] -visible = false -margin_top = 852.0 -margin_right = 700.0 -margin_bottom = 905.0 +margin_left = 0.0 +margin_top = 1019.0 +margin_right = 1920.0 +margin_bottom = 1039.0 +text = "git commit --allow-empty" align = 0 [node name="Button2" parent="Control" instance=ExtResource( 4 )] visible = false -margin_top = 905.0 -margin_right = 700.0 -margin_bottom = 958.0 +margin_left = 0.0 +margin_top = 1019.0 +margin_right = 1920.0 +margin_bottom = 1039.0 text = "git switch -c $RANDOM" align = 0