From 7a2f82cdc6d1a1cea46454d42a4a51aa035da506 Mon Sep 17 00:00:00 2001 From: Manuel Menendez Alfonso Date: Wed, 13 Aug 2025 12:57:13 +0200 Subject: [PATCH 1/2] Add option to exclude draft PRs from repository widget --- internal/glance/widget-repository.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/glance/widget-repository.go b/internal/glance/widget-repository.go index 1eeb8b4..fe9b324 100644 --- a/internal/glance/widget-repository.go +++ b/internal/glance/widget-repository.go @@ -19,6 +19,7 @@ type repositoryWidget struct { PullRequestsLimit int `yaml:"pull-requests-limit"` IssuesLimit int `yaml:"issues-limit"` CommitsLimit int `yaml:"commits-limit"` + ExcludeDraftPRs bool `yaml:"exclude-draft-prs"` Repository repository `yaml:"-"` } @@ -47,6 +48,7 @@ func (widget *repositoryWidget) update(ctx context.Context) { widget.PullRequestsLimit, widget.IssuesLimit, widget.CommitsLimit, + widget.ExcludeDraftPRs, ) if !widget.canContinueUpdateAfterHandlingErr(err) { @@ -111,13 +113,23 @@ type gitHubCommitResponseJson struct { } `json:"commit"` } -func fetchRepositoryDetailsFromGithub(repo string, token string, maxPRs int, maxIssues int, maxCommits int) (repository, error) { +func buildPRQuery(repo string, excludeDraftPRs bool) string { + query := fmt.Sprintf("is:pr+is:open+repo:%s", repo) + if excludeDraftPRs { + query += "+-is:draft" + } + return query +} + +func fetchRepositoryDetailsFromGithub(repo string, token string, maxPRs int, maxIssues int, maxCommits int, excludeDraftPRs bool) (repository, error) { repositoryRequest, err := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s", repo), nil) if err != nil { return repository{}, fmt.Errorf("%w: could not create request with repository: %v", errNoContent, err) } - PRsRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/search/issues?q=is:pr+is:open+repo:%s&per_page=%d", repo, maxPRs), nil) + prQuery := buildPRQuery(repo, excludeDraftPRs) + + PRsRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/search/issues?q=%s&per_page=%d", prQuery, maxPRs), nil) issuesRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/search/issues?q=is:issue+is:open+repo:%s&per_page=%d", repo, maxIssues), nil) CommitsRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s/commits?per_page=%d", repo, maxCommits), nil) From b6b4c84f550ac070d73a2d379b615a1eee99b064 Mon Sep 17 00:00:00 2001 From: Manuel Menendez Alfonso Date: Thu, 14 Aug 2025 12:08:57 +0200 Subject: [PATCH 2/2] Document option to exclude draft pull requests --- docs/configuration.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 174de83..de4ac13 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2499,6 +2499,7 @@ Example: pull-requests-limit: 5 issues-limit: 3 commits-limit: 3 + exclude-draft-prs: true ``` Preview: @@ -2514,6 +2515,7 @@ Preview: | pull-requests-limit | integer | no | 3 | | issues-limit | integer | no | 3 | | commits-limit | integer | no | -1 | +| exclude-draft-prs | boolean | no | false | ##### `repository` The owner and repository name that will have their information displayed. @@ -2530,6 +2532,9 @@ The maximum number of latest open issues to show. Set to `-1` to not show any. ##### `commits-limit` The maximum number of lastest commits to show from the default branch. Set to `-1` to not show any. +##### `exclude-draft-prs` +Wheter to exclude draft pull requests from the list. Set to `false` by default to include them. + ### Bookmarks Display a list of links which can be grouped.