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

Function NewChecksCommand

pkg/cli/checks_command.go:72–118  ·  view source on GitHub ↗

NewChecksCommand creates the checks command.

()

Source from the content-addressed store, hash-verified

70
71// NewChecksCommand creates the checks command.
72func NewChecksCommand() *cobra.Command {
73 cmd := &cobra.Command{
74 Use: "checks <pr-number>",
75 Short: "Classify CI check state for a pull request",
76 Long: `Classify CI check state for a pull request and emit a normalized result.
77
78Maps PR check rollups to one of the following normalized states:
79 success - all checks passed
80 failed - one or more checks failed
81 pending - checks are still running or queued
82 no_checks - no checks configured or triggered
83 policy_blocked - policy or account gates are blocking the PR
84
85` + "Raw check run and commit status signals are included in JSON output." + `
86
87JSON output includes two state fields:
88 state - aggregate state across all check runs and commit statuses
89 required_state - state derived from check runs and policy commit statuses only;
90 ignores optional third-party commit statuses (e.g., Vercel,
91 Netlify deployments) but still surfaces policy_blocked when
92 branch-protection or account-gate statuses fail
93
94Use required_state as the authoritative CI verdict in repos that have optional
95deployment integrations posting commit statuses alongside required CI checks.`,
96 Example: ` ` + string(constants.CLIExtensionPrefix) + ` checks 42 # Classify checks for PR #42
97 ` + string(constants.CLIExtensionPrefix) + ` checks 42 --repo owner/repo # Specify repository
98 ` + string(constants.CLIExtensionPrefix) + ` checks 42 --json # Output in JSON format`,
99 Args: cobra.ExactArgs(1),
100 RunE: func(cmd *cobra.Command, args []string) error {
101 repo, _ := cmd.Flags().GetString("repo")
102 jsonOutput, _ := cmd.Flags().GetBool("json")
103
104 config := ChecksConfig{
105 Repo: repo,
106 PRNumber: args[0],
107 JSONOutput: jsonOutput,
108 }
109
110 return RunChecks(config)
111 },
112 }
113
114 addRepoFlag(cmd)
115 addJSONFlag(cmd)
116
117 return cmd
118}
119
120// RunChecks executes the checks command with the given configuration.
121func RunChecks(config ChecksConfig) error {

Callers 6

initFunction · 0.92
TestChecksCommandFunction · 0.85

Calls 4

RunChecksFunction · 0.85
addRepoFlagFunction · 0.85
addJSONFlagFunction · 0.85
GetStringMethod · 0.65