mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-08-30 18:22:19 +00:00
feat: let commits-per-repo 0 mean every commit
The pagination guard broke on seen >= maxPerRepo, so a cap of 0 stopped before the first page and rendered empty productive-time, productive-weekday and most-commit-language cards. That inverted the meaning 0 carries for top-repos, where it already means unlimited. Treat a cap of 0 or less as no cap. Verified against a real repo: a cap of 100 still stops at 100, while 500 and 0 both walk the full 382-commit history.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package github
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestReachedCommitCap(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
seen int
|
||||
maxPerRepo int
|
||||
want bool
|
||||
}{
|
||||
{"under the cap", 100, 500, false},
|
||||
{"at the cap", 500, 500, true},
|
||||
{"past the cap", 700, 500, true},
|
||||
// Zero means unlimited, so even a fresh repo keeps paginating. The
|
||||
// old behavior stopped here and rendered empty commit-derived cards.
|
||||
{"zero cap, nothing seen yet", 0, 0, false},
|
||||
{"zero cap, deep into history", 100_000, 0, false},
|
||||
{"negative cap treated as unlimited", 10, -1, false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := reachedCommitCap(tc.seen, tc.maxPerRepo); got != tc.want {
|
||||
t.Errorf("%s: reachedCommitCap(%d, %d) = %v, want %v",
|
||||
tc.name, tc.seen, tc.maxPerRepo, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user