MCPcopy Create free account
hub / github.com/github/gh-aw / checkGHAuthStatusShared

Function checkGHAuthStatusShared

pkg/cli/preconditions.go:18–39  ·  view source on GitHub ↗

checkGHAuthStatusShared verifies the user is logged in to GitHub CLI

(verbose bool)

Source from the content-addressed store, hash-verified

16
17// checkGHAuthStatusShared verifies the user is logged in to GitHub CLI
18func checkGHAuthStatusShared(verbose bool) error {
19 preconditionsLog.Print("Checking GitHub CLI authentication status")
20
21 output, err := workflow.RunGHCombined("Checking GitHub authentication...", "auth", "status")
22
23 if err != nil {
24 fmt.Fprintln(os.Stderr, console.FormatErrorMessage("You are not logged in to GitHub CLI."))
25 fmt.Fprintln(os.Stderr, "")
26 fmt.Fprintln(os.Stderr, "Please run the following command to authenticate:")
27 fmt.Fprintln(os.Stderr, "")
28 fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" gh auth login"))
29 fmt.Fprintln(os.Stderr, "")
30 return errors.New("not authenticated with GitHub CLI")
31 }
32
33 if verbose {
34 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("GitHub CLI authenticated"))
35 preconditionsLog.Printf("gh auth status output: %s", string(output))
36 }
37
38 return nil
39}
40
41// checkActionsEnabledShared verifies that GitHub Actions is enabled for the repository
42// and that the allowed actions settings permit running agentic workflows

Callers 1

checkGHAuthStatusMethod · 0.85

Calls 6

RunGHCombinedFunction · 0.92
FormatErrorMessageFunction · 0.92
FormatCommandMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected