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

Function ParseFullReference

pkg/cmd/pr/shared/finder.go:335–354  ·  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

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

Callers 1

TestParseFullReferenceFunction · 0.85

Calls 2

NewFunction · 0.92
ErrorfMethod · 0.65

Tested by 1

TestParseFullReferenceFunction · 0.68