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

Function createOrgIssue

pkg/cli/org_issue_pr_helpers.go:214–239  ·  view source on GitHub ↗

createOrgIssue creates a GitHub issue with the given title, body, and label. If creating with the label fails (e.g. label does not exist), it retries once without the label so the issue is always created.

(ctx context.Context, repo, title, body, label string)

Source from the content-addressed store, hash-verified

212// creating with the label fails (e.g. label does not exist), it retries once without
213// the label so the issue is always created.
214func createOrgIssue(ctx context.Context, repo, title, body, label string) error {
215 endpoint := fmt.Sprintf("/repos/%s/issues", repo)
216 remoteHost := getHostFromOriginRemote()
217 output, err := runOrgAPICombined(ctx, remoteHost, "Creating issue...",
218 "--method", "POST",
219 endpoint,
220 "-f", "title="+title,
221 "-f", "body="+body,
222 "-f", "labels[]="+label,
223 )
224 if err == nil {
225 return nil
226 }
227 if !isLabelValidationError(output, err) {
228 return err
229 }
230 // Label may not exist; retry without it so the issue is always created.
231 orgIPLog.Printf("Failed to create issue with label %q, retrying without: %v", label, err)
232 _, err = runOrgAPI(ctx, remoteHost, "Creating issue...",
233 "--method", "POST",
234 endpoint,
235 "-f", "title="+title,
236 "-f", "body="+body,
237 )
238 return err
239}

Calls 5

getHostFromOriginRemoteFunction · 0.85
runOrgAPICombinedFunction · 0.85
isLabelValidationErrorFunction · 0.85
runOrgAPIFunction · 0.85
PrintfMethod · 0.45