MCPcopy
hub / github.com/cli/cli / ResolveIssueRef

Function ResolveIssueRef

pkg/cmd/issue/shared/lookup.go:215–230  ·  view source on GitHub ↗

ResolveIssueRef parses an issue reference (number or URL) and returns its node ID. References that point at a different host than baseRepo are rejected because relationship mutations require IDs from the base host.

(client *api.Client, baseRepo ghrepo.Interface, ref string)

Source from the content-addressed store, hash-verified

213// node ID. References that point at a different host than baseRepo are
214// rejected because relationship mutations require IDs from the base host.
215func ResolveIssueRef(client *api.Client, baseRepo ghrepo.Interface, ref string) (string, error) {
216 number, repo, err := ParseIssueFromArg(ref)
217 if err != nil {
218 return "", err
219 }
220
221 targetRepo := baseRepo
222 if r, ok := repo.Value(); ok {
223 if r.RepoHost() != baseRepo.RepoHost() {
224 return "", fmt.Errorf("issue reference %q belongs to a different host (%s) than the current repository (%s)", ref, r.RepoHost(), baseRepo.RepoHost())
225 }
226 targetRepo = r
227 }
228
229 return api.IssueNodeID(client, targetRepo, number)
230}
231
232// ResolveIssueTypeName resolves an issue type name to its node ID by
233// fetching the repository's available types.

Callers

nothing calls this directly

Calls 5

IssueNodeIDFunction · 0.92
ParseIssueFromArgFunction · 0.85
ValueMethod · 0.80
RepoHostMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected