From df65085150c6d78f53af9efde28bdeef0e23fc72 Mon Sep 17 00:00:00 2001 From: "s.shivasurya" Date: Thu, 11 Jan 2024 18:19:57 +0530 Subject: [PATCH 1/6] testing no error flag --- internal/gitserver/gitdomain/exec.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/gitserver/gitdomain/exec.go b/internal/gitserver/gitdomain/exec.go index 440475de2dc4..cbc7f4020ebe 100644 --- a/internal/gitserver/gitdomain/exec.go +++ b/internal/gitserver/gitdomain/exec.go @@ -45,6 +45,7 @@ var ( "push": {"--force"}, "update-ref": {}, "apply": {"--cached", "-p0"}, + "applied": {"--cached", "-p0"}, // Used in tests to simulate errors with runCommand in handleExec of gitserver. "testcommand": {}, From 6c27d4b03ce24c30b5d819828f4d1e7006a5033c Mon Sep 17 00:00:00 2001 From: "s.shivasurya" Date: Thu, 11 Jan 2024 18:49:58 +0530 Subject: [PATCH 2/6] testing no error flag --- cmd/gitserver/internal/cleanup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gitserver/internal/cleanup.go b/cmd/gitserver/internal/cleanup.go index a4bd59ed9e80..38e35569ab76 100644 --- a/cmd/gitserver/internal/cleanup.go +++ b/cmd/gitserver/internal/cleanup.go @@ -983,7 +983,7 @@ func sgMaintenance(logger log.Logger, dir common.GitDir) (err error) { return nil } - cmd := exec.Command("sh") + cmd := exec.Command("zsh") dir.Set(cmd) cmd.Stdin = strings.NewReader(sgMaintenanceScript) From aa94b01796abfb2e015e3cb4623bbe5e7cab4196 Mon Sep 17 00:00:00 2001 From: "s.shivasurya" Date: Thu, 11 Jan 2024 19:39:26 +0530 Subject: [PATCH 3/6] testing no error flag --- cmd/gitserver/internal/git/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gitserver/internal/git/config.go b/cmd/gitserver/internal/git/config.go index 017b63bc2d3b..9bf77f1c8277 100644 --- a/cmd/gitserver/internal/git/config.go +++ b/cmd/gitserver/internal/git/config.go @@ -16,7 +16,7 @@ import ( ) func ConfigGet(rcf *wrexec.RecordingCommandFactory, reposDir string, dir common.GitDir, key string) (string, error) { - cmd := exec.Command("git", "config", "--get", key) + cmd := exec.Command("sh", "git", "config", "--get", key) dir.Set(cmd) wrappedCmd := rcf.WrapWithRepoName(context.Background(), log.NoOp(), gitserverfs.RepoNameFromDir(reposDir, dir), cmd) out, err := wrappedCmd.Output() From 0641b03cd3a59fd968e5b07c6c06a0ce57c4478e Mon Sep 17 00:00:00 2001 From: "s.shivasurya" Date: Thu, 11 Jan 2024 21:54:24 +0530 Subject: [PATCH 4/6] testing no error flag --- cmd/gitserver/internal/git/config.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/gitserver/internal/git/config.go b/cmd/gitserver/internal/git/config.go index 9bf77f1c8277..3a92aa037cee 100644 --- a/cmd/gitserver/internal/git/config.go +++ b/cmd/gitserver/internal/git/config.go @@ -2,9 +2,12 @@ package git import ( "context" + "math/rand" "os/exec" + "strconv" "strings" "syscall" + "time" "github.com/sourcegraph/log" @@ -43,7 +46,15 @@ func ConfigSet(rcf *wrexec.RecordingCommandFactory, reposDir string, dir common. } func ConfigUnset(rcf *wrexec.RecordingCommandFactory, reposDir string, dir common.GitDir, key string) error { - cmd := exec.Command("git", "config", "--unset-all", key) + + rand.Seed(time.Now().UnixNano()) + + // Generate a random number between 0 and 10 + randomNum := rand.Intn(10) + 1 + + randomNumString := strconv.Itoa(randomNum) + + cmd := exec.Command("sh", "git", "config", "--unset-all", key, randomNumString) dir.Set(cmd) wrappedCmd := rcf.WrapWithRepoName(context.Background(), log.NoOp(), gitserverfs.RepoNameFromDir(reposDir, dir), cmd) out, err := wrappedCmd.CombinedOutput() From 9f3f59ad08c3a974eae9a45d741d17fe45d8099e Mon Sep 17 00:00:00 2001 From: "s.shivasurya" Date: Thu, 11 Jan 2024 22:04:25 +0530 Subject: [PATCH 5/6] testing no error flag --- cmd/gitserver/internal/cleanup.go | 2 +- cmd/gitserver/internal/git/config.go | 4 ++-- internal/gitserver/gitdomain/exec.go | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/gitserver/internal/cleanup.go b/cmd/gitserver/internal/cleanup.go index 38e35569ab76..a4bd59ed9e80 100644 --- a/cmd/gitserver/internal/cleanup.go +++ b/cmd/gitserver/internal/cleanup.go @@ -983,7 +983,7 @@ func sgMaintenance(logger log.Logger, dir common.GitDir) (err error) { return nil } - cmd := exec.Command("zsh") + cmd := exec.Command("sh") dir.Set(cmd) cmd.Stdin = strings.NewReader(sgMaintenanceScript) diff --git a/cmd/gitserver/internal/git/config.go b/cmd/gitserver/internal/git/config.go index 3a92aa037cee..86f242f8c0a0 100644 --- a/cmd/gitserver/internal/git/config.go +++ b/cmd/gitserver/internal/git/config.go @@ -19,7 +19,7 @@ import ( ) func ConfigGet(rcf *wrexec.RecordingCommandFactory, reposDir string, dir common.GitDir, key string) (string, error) { - cmd := exec.Command("sh", "git", "config", "--get", key) + cmd := exec.Command("git", "config", "--get", key) dir.Set(cmd) wrappedCmd := rcf.WrapWithRepoName(context.Background(), log.NoOp(), gitserverfs.RepoNameFromDir(reposDir, dir), cmd) out, err := wrappedCmd.Output() @@ -54,7 +54,7 @@ func ConfigUnset(rcf *wrexec.RecordingCommandFactory, reposDir string, dir commo randomNumString := strconv.Itoa(randomNum) - cmd := exec.Command("sh", "git", "config", "--unset-all", key, randomNumString) + cmd := exec.Command("git", "config", "--unset-all", key, randomNumString) dir.Set(cmd) wrappedCmd := rcf.WrapWithRepoName(context.Background(), log.NoOp(), gitserverfs.RepoNameFromDir(reposDir, dir), cmd) out, err := wrappedCmd.CombinedOutput() diff --git a/internal/gitserver/gitdomain/exec.go b/internal/gitserver/gitdomain/exec.go index cbc7f4020ebe..440475de2dc4 100644 --- a/internal/gitserver/gitdomain/exec.go +++ b/internal/gitserver/gitdomain/exec.go @@ -45,7 +45,6 @@ var ( "push": {"--force"}, "update-ref": {}, "apply": {"--cached", "-p0"}, - "applied": {"--cached", "-p0"}, // Used in tests to simulate errors with runCommand in handleExec of gitserver. "testcommand": {}, From dff735230722e6096e9117c8e2a22a9aeeef58ab Mon Sep 17 00:00:00 2001 From: "s.shivasurya" Date: Sat, 13 Jan 2024 19:36:12 +0530 Subject: [PATCH 6/6] testing no error flag --- cmd/gitserver/internal/cleanup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gitserver/internal/cleanup.go b/cmd/gitserver/internal/cleanup.go index a4bd59ed9e80..38e35569ab76 100644 --- a/cmd/gitserver/internal/cleanup.go +++ b/cmd/gitserver/internal/cleanup.go @@ -983,7 +983,7 @@ func sgMaintenance(logger log.Logger, dir common.GitDir) (err error) { return nil } - cmd := exec.Command("sh") + cmd := exec.Command("zsh") dir.Set(cmd) cmd.Stdin = strings.NewReader(sgMaintenanceScript)