Skip to content

Commit 37abbf1

Browse files
authored
Add an additional thing for push in case of https (#69)
1 parent 6a0de7c commit 37abbf1

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

clients/git/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func Push(repoDir string) error {
8282
cmd.Dir = repoDir
8383
cmd.Stdout = os.Stdout
8484
cmd.Stderr = os.Stderr
85+
cmd.Stdin = os.Stdin
8586
return cmd.Run()
8687
}
8788

cmd/app/helper.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ func getApplicationIDFromDir(dir string) (string, error) {
5858

5959
// canUseSSH checks if SSH is available and configured for git
6060
func canUseSSH() bool {
61-
// Check if ssh-agent is running and has keys
62-
cmd := exec.Command("ssh-add", "-l")
63-
err := cmd.Run()
64-
return err == nil
61+
// Test actual SSH connectivity to GitHub
62+
// ssh -T returns exit code 1 even on success (no shell access), so we check output
63+
cmd := exec.Command("ssh", "-T", "-o", "BatchMode=yes", "-o", "ConnectTimeout=5", "git@github.com")
64+
output, _ := cmd.CombinedOutput() // Ignore error since exit code 1 is expected on success
65+
66+
// GitHub returns "Hi <username>! You've successfully authenticated..." on success
67+
return strings.Contains(string(output), "successfully authenticated")
6568
}
6669

6770
// cloneRepository clones a repository using SSH or HTTPS based on availability

0 commit comments

Comments
 (0)