From 9cf7f0f6b53534d14291977d4c86e1f4a93d5293 Mon Sep 17 00:00:00 2001 From: iQQBot Date: Fri, 12 May 2023 20:42:02 +0000 Subject: [PATCH 1/3] persistence command history --- components/supervisor/pkg/supervisor/supervisor.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 41c95a8b80961a..b4334833b34a0e 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -1006,6 +1006,9 @@ func buildChildProcEnv(cfg *Config, envvars []string, runGP bool) []string { envs["JAVA_TOOL_OPTIONS"] += fmt.Sprintf(" -Xmx%sm", mem) } + envs["HISTFILE"] = "/workspace/.gitpod/.bash_history" + envs["PROMPT_COMMAND"] = "history -a" + var env, envn []string for nme, val := range envs { log.WithField("envvar", nme).Debug("passing environment variable to IDE") From 188fd4c2377a8eb5d129a27c700f4f049879c24d Mon Sep 17 00:00:00 2001 From: iQQBot Date: Mon, 15 May 2023 09:13:05 +0000 Subject: [PATCH 2/3] fix test --- .../pkg/supervisor/supervisor_test.go | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/components/supervisor/pkg/supervisor/supervisor_test.go b/components/supervisor/pkg/supervisor/supervisor_test.go index 911ee832b70f59..9ae1d794ef8de5 100644 --- a/components/supervisor/pkg/supervisor/supervisor_test.go +++ b/components/supervisor/pkg/supervisor/supervisor_test.go @@ -21,6 +21,8 @@ func TestBuildChildProcEnv(t *testing.T) { "SUPERVISOR_ADDR=localhost:8080", "HOME=/home/gitpod", "USER=gitpod", + "HISTFILE=/workspace/.gitpod/.bash_history", + "PROMPT_COMMAND=history -a", ) } @@ -85,16 +87,18 @@ func TestBuildChildProcEnv(t *testing.T) { }, }, { - Name: "ots", - Input: []string{}, - OTS: `[{"name":"foo","value":"bar"},{"name":"GITPOD_TOKENS","value":"foobar"}]`, - Expectation: []string{"HOME=/home/gitpod", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod", "foo=bar"}, + Name: "ots", + Input: []string{}, + OTS: `[{"name":"foo","value":"bar"},{"name":"GITPOD_TOKENS","value":"foobar"}]`, + Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.bash_history", + "PROMPT_COMMAND=history -a", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod", "foo=bar"}, }, { - Name: "failed ots", - Input: []string{}, - OTS: `invalid json`, - Expectation: []string{"HOME=/home/gitpod", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod"}, + Name: "failed ots", + Input: []string{}, + OTS: `invalid json`, + Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.bash_history", + "PROMPT_COMMAND=history -a", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod"}, }, } From 1e6581e8e8904d76e7ba32fd55a9f76cf00b9115 Mon Sep 17 00:00:00 2001 From: iQQBot Date: Mon, 15 May 2023 09:48:27 +0000 Subject: [PATCH 3/3] addressed feedback --- components/supervisor/pkg/supervisor/supervisor.go | 6 ++++-- components/supervisor/pkg/supervisor/supervisor_test.go | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index b4334833b34a0e..c33512eab77b4c 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -1006,8 +1006,10 @@ func buildChildProcEnv(cfg *Config, envvars []string, runGP bool) []string { envs["JAVA_TOOL_OPTIONS"] += fmt.Sprintf(" -Xmx%sm", mem) } - envs["HISTFILE"] = "/workspace/.gitpod/.bash_history" - envs["PROMPT_COMMAND"] = "history -a" + if _, ok := envs["HISTFILE"]; !ok { + envs["HISTFILE"] = "/workspace/.gitpod/.shell_history" + envs["PROMPT_COMMAND"] = "history -a" + } var env, envn []string for nme, val := range envs { diff --git a/components/supervisor/pkg/supervisor/supervisor_test.go b/components/supervisor/pkg/supervisor/supervisor_test.go index 9ae1d794ef8de5..961e7a11433f66 100644 --- a/components/supervisor/pkg/supervisor/supervisor_test.go +++ b/components/supervisor/pkg/supervisor/supervisor_test.go @@ -21,7 +21,7 @@ func TestBuildChildProcEnv(t *testing.T) { "SUPERVISOR_ADDR=localhost:8080", "HOME=/home/gitpod", "USER=gitpod", - "HISTFILE=/workspace/.gitpod/.bash_history", + "HISTFILE=/workspace/.gitpod/.shell_history", "PROMPT_COMMAND=history -a", ) } @@ -90,14 +90,14 @@ func TestBuildChildProcEnv(t *testing.T) { Name: "ots", Input: []string{}, OTS: `[{"name":"foo","value":"bar"},{"name":"GITPOD_TOKENS","value":"foobar"}]`, - Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.bash_history", + Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.shell_history", "PROMPT_COMMAND=history -a", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod", "foo=bar"}, }, { Name: "failed ots", Input: []string{}, OTS: `invalid json`, - Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.bash_history", + Expectation: []string{"HOME=/home/gitpod", "HISTFILE=/workspace/.gitpod/.shell_history", "PROMPT_COMMAND=history -a", "SUPERVISOR_ADDR=localhost:8080", "USER=gitpod"}, }, }