CheckGHCLI validates that the GitHub CLI is installed and authenticated.
()
| 10 | |
| 11 | // CheckGHCLI validates that the GitHub CLI is installed and authenticated. |
| 12 | func CheckGHCLI() (installed bool, authenticated bool, err error) { |
| 13 | // Check if gh is installed |
| 14 | _, err = exec.LookPath("gh") |
| 15 | if err != nil { |
| 16 | return false, false, nil |
| 17 | } |
| 18 | |
| 19 | // Check if gh is authenticated |
| 20 | cmd := exec.Command("gh", "auth", "status") |
| 21 | if err := cmd.Run(); err != nil { |
| 22 | return true, false, nil |
| 23 | } |
| 24 | |
| 25 | return true, true, nil |
| 26 | } |
| 27 | |
| 28 | // PushBranch pushes the branch to origin. |
| 29 | func PushBranch(dir, branch string) error { |