MCPcopy
hub / github.com/cli/cli / GetWithComments

Method GetWithComments

pkg/cmd/discussion/client/client.go:538–638  ·  view source on GitHub ↗
(repo ghrepo.Interface, number int32, limit int, after string, newest bool)

Source from the content-addressed store, hash-verified

536}
537
538func (c *discussionClient) GetWithComments(repo ghrepo.Interface, number int32, limit int, after string, newest bool) (*Discussion, error) {
539 meta, err := c.getRepositoryMeta(repo)
540 if err != nil {
541 return nil, err
542 }
543 if !meta.HasDiscussionsEnabled {
544 return nil, fmt.Errorf("the '%s/%s' repository has discussions disabled", repo.RepoOwner(), repo.RepoName())
545 }
546
547 var query struct {
548 Repository struct {
549 Discussion struct {
550 discussionListNode
551 Comments struct {
552 TotalCount int
553 PageInfo struct {
554 EndCursor string
555 HasNextPage bool
556 StartCursor string
557 HasPreviousPage bool
558 }
559 Nodes []discussionCommentNode
560 } `graphql:"comments(first: $first, last: $last, after: $after, before: $before)"`
561 } `graphql:"discussion(number: $number)"`
562 } `graphql:"repository(owner: $owner, name: $name)"`
563 }
564
565 variables := map[string]interface{}{
566 "owner": githubv4.String(repo.RepoOwner()),
567 "name": githubv4.String(repo.RepoName()),
568 "number": githubv4.Int(number),
569 "first": (*githubv4.Int)(nil),
570 "last": (*githubv4.Int)(nil),
571 "after": (*githubv4.String)(nil),
572 "before": (*githubv4.String)(nil),
573 }
574
575 if newest {
576 variables["last"] = githubv4.Int(min(limit, maxPageSize))
577 if after != "" {
578 variables["before"] = githubv4.String(after)
579 }
580 } else {
581 variables["first"] = githubv4.Int(min(limit, maxPageSize))
582 if after != "" {
583 variables["after"] = githubv4.String(after)
584 }
585 }
586
587 if err := c.gql.Query(repo.RepoHost(), "DiscussionWithComments", &query, variables); err != nil {
588 return nil, err
589 }
590
591 src := query.Repository.Discussion
592
593 d := mapDiscussionFromListNode(src.discussionListNode)
594
595 for _, rg := range src.ReactionGroups {

Callers

nothing calls this directly

Calls 10

getRepositoryMetaMethod · 0.95
mapCommentFromNodeFunction · 0.85
ErrorfMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65
minFunction · 0.50
StringMethod · 0.45

Tested by

no test coverage detected