MCPcopy Create free account
hub / github.com/cli/cli / ParseFullReference

Function ParseFullReference

pkg/cmd/pr/shared/finder.go:333–352  ·  view source on GitHub ↗

ParseFullReference parses a short issue/pull request reference of the form "owner/repo#number", where owner, repo and number are all required.

(s string)

Source from the content-addressed store, hash-verified

331// ParseFullReference parses a short issue/pull request reference of the form
332// "owner/repo#number", where owner, repo and number are all required.
333func ParseFullReference(s string) (ghrepo.Interface, int, error) {
334 if s == "" {
335 return nil, 0, errors.New("empty reference")
336 }
337
338 m := fullReferenceRE.FindStringSubmatch(s)
339 if m == nil {
340 return nil, 0, fmt.Errorf("invalid reference: %q", s)
341 }
342
343 number, err := strconv.Atoi(m[3])
344 if err != nil {
345 return nil, 0, fmt.Errorf("invalid reference: %q; %w", s, err)
346 }
347
348 owner := m[1]
349 repo := m[2]
350
351 return ghrepo.New(owner, repo), number, nil
352}
353
354func findByNumber(httpClient *http.Client, repo ghrepo.Interface, number int, fields []string) (*api.PullRequest, error) {
355 type response struct {

Callers 1

TestParseFullReferenceFunction · 0.85

Calls 2

NewFunction · 0.92
ErrorfMethod · 0.65

Tested by 1

TestParseFullReferenceFunction · 0.68