From f72b35f16eed2a7ed790c69f99135a45174dc632 Mon Sep 17 00:00:00 2001 From: Robert Martens Date: Fri, 24 Oct 2025 12:57:07 -0400 Subject: [PATCH] Fix empty ssh-agent fallback --- pkg/git/git.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/git/git.go b/pkg/git/git.go index c5cd032..60b7efc 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -133,6 +133,8 @@ func getSSHAuth() (transport.AuthMethod, error) { if authSock := os.Getenv("SSH_AUTH_SOCK"); authSock != "" { conn, err := net.Dial("unix", authSock) if err == nil { + defer func() { _ = conn.Close() }() + agentClient := agent.NewClient(conn) keys, err := agentClient.List() if err == nil && len(keys) > 0 { @@ -141,16 +143,9 @@ func getSSHAuth() (transport.AuthMethod, error) { return auth, nil } } - _ = conn.Close() } } - // Fallback to go-git's SSH agent implementation - auth, err := gitssh.NewSSHAgentAuth("git") - if err == nil { - return auth, nil - } - // Fallback to default SSH key locations homeDir, err := os.UserHomeDir() if err != nil {