Skip to content

Commit

Permalink
Apply LookPath fix to the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
jchadwick-buf committed Feb 7, 2024
1 parent c491a2f commit f24d2a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 0 additions & 8 deletions private/pkg/command/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ func (r *runner) Start(name string, options ...StartOption) (Process, error) {
for _, option := range options {
option(execOptions)
}
// In Golang 1.22, the behavior of exec.Command was changed so that LookPath is no longer called.
// This preserves the behavior.
// https://cs.opensource.google/go/go/+/f7f266c88598398dcf32b448bcea2100e1702630:src/os/exec/exec.go;dlc=07d4de9312aef72d1bd7427316a2ac21b83e4a20
// https://tip.golang.org/doc/go1.22 (search for "LookPath")
name, err := exec.LookPath(name)
if err != nil {
return nil, err
}
cmd := exec.Command(name, execOptions.args...)
execOptions.ApplyToCmd(cmd)
r.increment()
Expand Down
7 changes: 6 additions & 1 deletion private/pkg/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ func createGitDirs(
gitExecPathBytes, err := command.RunStdout(ctx, container, runner, "git", "--exec-path")
require.NoError(t, err)
gitExecPath := strings.TrimSpace(string(gitExecPathBytes))
gitHTTPBackendPath := filepath.Join(gitExecPath, "git-http-backend")
// In Golang 1.22, the behavior of "os/exec" was changed so that LookPath is no longer called
// in some cases. This preserves the behavior.
// https://cs.opensource.google/go/go/+/f7f266c88598398dcf32b448bcea2100e1702630:src/os/exec/exec.go;dlc=07d4de9312aef72d1bd7427316a2ac21b83e4a20
// https://tip.golang.org/doc/go1.22 (search for "LookPath")
gitHTTPBackendPath, err := exec.LookPath(filepath.Join(gitExecPath, "git-http-backend"))
require.NoError(t, err)
t.Logf("gitHttpBackendPath=%q submodulePath=%q", gitHTTPBackendPath, submodulePath)
// https://git-scm.com/docs/git-http-backend#_description
f, err := os.Create(filepath.Join(submodulePath, ".git", "git-daemon-export-ok"))
Expand Down

0 comments on commit f24d2a4

Please sign in to comment.