@@ -10,6 +10,7 @@ import (
10
10
"github.com/neel1996/gitconvex-server/global"
11
11
"github.com/neel1996/gitconvex-server/utils"
12
12
"io"
13
+ "strings"
13
14
)
14
15
15
16
// windowsPush is used for pushing changes using the git client if the platform is windows
@@ -32,13 +33,14 @@ func windowsPush(repoPath string, remoteName string, branch string) string {
32
33
// By default it will choose the current branch and pushes to the matching remote branch
33
34
func PushToRemote (repo * git.Repository , remoteName string , remoteBranch string ) string {
34
35
targetRefPsec := "refs/heads/" + remoteBranch + ":refs/heads/" + remoteBranch
36
+ w , _ := repo .Worktree ()
37
+
35
38
b := new (bytes.Buffer )
36
39
sshAuth , sshErr := ssh .NewSSHAgentAuth ("git" )
37
40
logger .Log (fmt .Sprintf ("Pushing changes to remote -> %s : %s" , remoteName , targetRefPsec ), global .StatusInfo )
38
41
39
42
if sshErr != nil {
40
43
logger .Log (fmt .Sprintf ("Authentication failed -> %s" , sshErr .Error ()), global .StatusError )
41
- w , _ := repo .Worktree ()
42
44
43
45
if w == nil {
44
46
return "PUSH_FAILED"
@@ -63,6 +65,10 @@ func PushToRemote(repo *git.Repository, remoteName string, remoteBranch string)
63
65
})
64
66
65
67
if err != nil {
68
+ if strings .Contains (err .Error (), "ssh: handshake failed: ssh:" ) {
69
+ logger .Log ("push failed. Retrying push with git client" , global .StatusWarning )
70
+ return windowsPush (w .Filesystem .Root (), remoteName , remoteBranch )
71
+ }
66
72
logger .Log (fmt .Sprintf ("Error occurred while pushing changes to -> %s : %s\n %s" , remoteName , targetRefPsec , err .Error ()), global .StatusError )
67
73
return "PUSH_FAILED"
68
74
} else {
0 commit comments