From aef52d6433af7ae2a9be571c1621e09c716b1a44 Mon Sep 17 00:00:00 2001 From: "Denis A. Altoe Falqueto" Date: Sat, 20 Sep 2025 14:11:36 -0300 Subject: [PATCH] Provide oauthClientId in a file This patch allows the user to configure a filename containing the value for oauthClientId. That would allow an easier handling of encrypted secrets with tools like agenix or git-crypt. --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 1ce26a3..8bcb8cf 100644 --- a/main.go +++ b/main.go @@ -236,10 +236,22 @@ func main() { } gitPath, err := exec.LookPath("git") if err == nil { - cmd := exec.Command(gitPath, "config", "--get-urlmatch", "credential.oauthClientId", urll) + // Use oauthClientIdFile first. If it's not found, fall back to oauthClientId + cmd := exec.Command(gitPath, "config", "--get-urlmatch", "credential.oauthClientIdFile", urll) bytes, err := cmd.Output() if err == nil { + var oauthClientIdFile = strings.TrimSpace(string(bytes)) + bytes, err := os.ReadFile(oauthClientIdFile) + if err != nil { + log.Fatalln(err) + } c.ClientID = strings.TrimSpace(string(bytes)) + } else { + cmd := exec.Command(gitPath, "config", "--get-urlmatch", "credential.oauthClientId", urll) + bytes, err := cmd.Output() + if err == nil { + c.ClientID = strings.TrimSpace(string(bytes)) + } } bytes, err = exec.Command(gitPath, "config", "--get-urlmatch", "credential.oauthClientSecret", urll).Output() if err == nil {