From 12ac3bb7d2a4258f403e3cf0422306a38c4ab889 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Tue, 9 Nov 2021 17:49:28 +0100 Subject: [PATCH] if git is not installed, no need to locate a credential helper --- clone.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clone.go b/clone.go index ed42816..4807a11 100644 --- a/clone.go +++ b/clone.go @@ -25,7 +25,15 @@ import ( ) func getCredentialHelper(url *neturl.URL) string { - cmd := exec.Command("git", "config", "--get-urlmatch", "credential.helper", url.String()) + git, err := exec.LookPath("git") + if err != nil { + if err != exec.ErrNotFound { + log.Printf("ERROR: failed to lookup git on path, %s", err) + } + return "" + } + + cmd := exec.Command(git, "config", "--get-urlmatch", "credential.helper", url.String()) helper, err := cmd.Output() if err == nil { return strings.TrimSpace(string(helper))