@@ -42,6 +42,12 @@ type Options struct {
4242 DenyList * filters.Filter `yaml:"deny-list"`
4343 // DuplicateIssueCheck is a bool to enable duplicate tracking issue check and update the newest
4444 DuplicateIssueCheck bool `yaml:"duplicate-issue-check" default:"false"`
45+ // DuplicateIssuePageSize controls how many issues are fetched per page when searching for duplicates.
46+ // If unset or <=0, a default of 100 is used.
47+ DuplicateIssuePageSize int `yaml:"duplicate-issue-page-size" default:"100"`
48+ // DuplicateIssueMaxPages limits how many pages are fetched when searching for duplicates.
49+ // If unset or <=0, all pages are fetched until exhaustion.
50+ DuplicateIssueMaxPages int `yaml:"duplicate-issue-max-pages" default:"0"`
4551
4652 HttpClient * retryablehttp.Client `yaml:"-"`
4753 OmitRaw bool `yaml:"-"`
@@ -151,21 +157,44 @@ func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
151157}
152158
153159func (i * Integration ) findIssueByTitle (title string ) (* gitea.Issue , error ) {
160+ // Fetch issues in pages to ensure older issues are also checked for duplicates.
161+ pageSize := i .options .DuplicateIssuePageSize
162+ if pageSize <= 0 {
163+ pageSize = 100
164+ }
165+ maxPages := i .options .DuplicateIssueMaxPages
154166
155- issueList , _ , err := i . client . ListRepoIssues ( i . options . ProjectOwner , i . options . ProjectName , gitea.ListIssueOption {
167+ opts := gitea.ListIssueOption {
156168 State : "all" ,
157- })
158- if err != nil {
159- return nil , err
169+ ListOptions : gitea.ListOptions {
170+ Page : 1 ,
171+ PageSize : pageSize ,
172+ },
160173 }
161174
162- for _ , issue := range issueList {
163- if issue . Title == title {
164- return issue , nil
175+ for {
176+ if maxPages > 0 && opts . Page > maxPages {
177+ return nil , nil
165178 }
166- }
167179
168- return nil , nil
180+ issueList , _ , err := i .client .ListRepoIssues (i .options .ProjectOwner , i .options .ProjectName , opts )
181+ if err != nil {
182+ return nil , err
183+ }
184+
185+ for _ , issue := range issueList {
186+ if issue .Title == title {
187+ return issue , nil
188+ }
189+ }
190+
191+ if len (issueList ) < opts .PageSize {
192+ // Last page reached.
193+ return nil , nil
194+ }
195+
196+ opts .Page ++
197+ }
169198}
170199
171200func (i * Integration ) getLabelIDsByNames (labels []string ) ([]int64 , error ) {
0 commit comments