Skip to content

Commit 067b15d

Browse files
committed
handle nil StdErr
1 parent 46d31e8 commit 067b15d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/git/GitBaseManager.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,18 @@ func (impl *GitManagerBaseImpl) runCommand(cmd *exec.Cmd) (response, errMsg stri
200200
output = strings.TrimSpace(output)
201201
if err != nil {
202202
impl.logger.Errorw("error in git cli operation", "msg", string(outBytes), "err", err)
203+
errMsg = output
203204
exErr, ok := err.(*exec.ExitError)
204205
if !ok {
205-
return output, string(outBytes), err
206+
return output, errMsg, err
206207
}
207208
if strings.Contains(output, AUTHENTICATION_FAILED_ERROR) {
208209
impl.logger.Errorw("authentication failed", "msg", string(outBytes), "err", err.Error())
209210
return output, "authentication failed", errors.New("authentication failed")
210211
}
212+
if exErr.Stderr == nil {
213+
return output, errMsg, err
214+
}
211215
errOutput := string(exErr.Stderr)
212216
return output, errOutput, err
213217
}

pkg/git/RepositoryManager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (impl *RepositoryManagerImpl) InitRepoAndGetSshPrivateKeyPath(gitCtx GitCon
123123
}()
124124
errMsg, err = impl.CleanupAndInitRepo(gitCtx, location, url)
125125
if err != nil {
126-
return "", "", err
126+
return "", errMsg, err
127127
}
128128
var sshPrivateKeyPath string
129129
// check ssh

0 commit comments

Comments
 (0)