MCPcopy Create free account
hub / github.com/git-bug/git-bug / Next

Method Next

bridge/jira/client.go:719–743  ·  view source on GitHub ↗

Next Return the next item in the result set and advance the iterator. Advancing the iterator may require fetching a new page.

()

Source from the content-addressed store, hash-verified

717// Next Return the next item in the result set and advance the iterator.
718// Advancing the iterator may require fetching a new page.
719func (ci *CommentIterator) Next() *Comment {
720 if ci.Err != nil {
721 return nil
722 }
723
724 comment := ci.message.Comments[ci.itemIdx]
725 if ci.itemIdx+1 < len(ci.message.Comments) {
726 // We still have an item left in the currently cached page
727 ci.itemIdx++
728 } else {
729 if ci.message.IsLastPage() {
730 ci.Err = errDone
731 } else {
732 // There are still more pages to fetch, so fetch the next page and
733 // cache it
734 ci.message, ci.Err = ci.client.GetComments(
735 ci.idOrKey, ci.pageSize, ci.message.NextStartAt())
736 // NOTE(josh): we don't deal with the error now, we just cache it.
737 // HasNext() will return false and the caller can check the error
738 // afterward.
739 ci.itemIdx = 0
740 }
741 }
742 return &comment
743}
744
745// IterComments returns an iterator over paginated comments within an issue
746func (client *Client) IterComments(idOrKey string, pageSize int) *CommentIterator {

Callers 1

ImportAllMethod · 0.95

Calls 3

GetCommentsMethod · 0.80
IsLastPageMethod · 0.45
NextStartAtMethod · 0.45

Tested by

no test coverage detected