Skip to content

Commit 4c39051

Browse files
authored
Merge pull request #10 from codeGROOVE-dev/sprinkler
minor code cleanup
2 parents c9f32ba + 0f119a4 commit 4c39051

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

main.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const (
137137
titlePadding = 5 // Space between title and URL
138138
minTitleLength = 20 // Minimum title display length
139139
cacheFileMode = 0o644 // File permissions for cache files
140+
stalePRDays = 90 // Days before a PR is considered stale
140141
)
141142

142143
// turnCache handles caching of Turn API responses.
@@ -537,10 +538,10 @@ func parseSearchResponse(resp *http.Response) ([]PR, error) {
537538
resetTime := resp.Header.Get("X-Ratelimit-Reset")
538539
return nil, fmt.Errorf("github api rate limit exceeded, resets at %s", resetTime)
539540
}
540-
return nil, handleHTTPError(resp, "github api access forbidden")
541+
return nil, fmt.Errorf("github api access forbidden: status %d", resp.StatusCode)
541542
}
542543
if resp.StatusCode != http.StatusOK {
543-
return nil, handleHTTPError(resp, "github api error")
544+
return nil, fmt.Errorf("github api error: status %d", resp.StatusCode)
544545
}
545546

546547
var result SearchResult
@@ -551,10 +552,6 @@ func parseSearchResponse(resp *http.Response) ([]PR, error) {
551552
return result.Items, nil
552553
}
553554

554-
func handleHTTPError(resp *http.Response, message string) error {
555-
return fmt.Errorf("%s: status %d", message, resp.StatusCode)
556-
}
557-
558555
func deduplicatePRs(prs []PR) []PR {
559556
if len(prs) <= 1 {
560557
return prs
@@ -1022,7 +1019,7 @@ func generatePRDisplay(prs []PR, username string, blockingOnly, verbose, include
10221019
// Filter stale PRs unless includeStale is true
10231020
if !includeStale {
10241021
var filteredPRs []PR
1025-
staleDuration := 90 * 24 * time.Hour // 90 days
1022+
staleDuration := stalePRDays * 24 * time.Hour
10261023
for i := range prs {
10271024
isStale := false
10281025

@@ -1129,7 +1126,7 @@ func generatePRDisplay(prs []PR, username string, blockingOnly, verbose, include
11291126
}
11301127
}
11311128

1132-
if blockingOnly && incomingBlockingCount == 0 {
1129+
if blockingOnly && incomingBlockingCount == 0 && outgoingBlockingCount == 0 {
11331130
// Show nothing when no PRs are blocking
11341131
return ""
11351132
}

0 commit comments

Comments
 (0)