diff --git a/internal/workflow/scan.go b/internal/workflow/scan.go index 9415ec4..0a7e552 100644 --- a/internal/workflow/scan.go +++ b/internal/workflow/scan.go @@ -136,7 +136,11 @@ func (s *Scanner) Members(hasWork bool) ([]string, error) { return out, nil } -// iterOrgRepos 產出 (org, repoName);空倉庫跳過(沒有內容可掃)。 +// iterOrgRepos 產出 (org, repoName)。空倉庫(empty)**不**跳過:Gitea 允許 +// 空倉庫持有 open issue(如「初始化項目」型工作),gitea.py 的 +// for_all_repositories(list_my_followup_issues/for_all_organizations) +// 掃 issue 時不檢查 empty;只有 PR 掃描(iterOpenPulls)、stalled 與 +// milestone overview 才跳過空倉庫。 func (s *Scanner) iterOrgRepos() ([][2]string, error) { orgs, err := s.Orgs() if err != nil { @@ -149,7 +153,7 @@ func (s *Scanner) iterOrgRepos() ([][2]string, error) { return nil, err } for _, repo := range repos { - if repo.Name == "" || repo.Empty { + if repo.Name == "" { continue } out = append(out, [2]string{org, repo.Name}) diff --git a/internal/workflow/scan_test.go b/internal/workflow/scan_test.go index bba9e9e..278a44f 100644 --- a/internal/workflow/scan_test.go +++ b/internal/workflow/scan_test.go @@ -164,6 +164,51 @@ func TestNextLayerFallbackToIssue(t *testing.T) { } } +// TestNextPicksIssueInEmptyRepo 回歸測試(#43):空倉庫(empty=true)中 +// 分派給目前帳號的 open issue 應被第三層拾取——gitea.py 的 +// for_all_repositories 掃 issue 不跳過空倉庫(「初始化項目」型工作)。 +func TestNextPicksIssueInEmptyRepo(t *testing.T) { + s, fc := newTestScanner() + fc.repos["alterminal"] = []Repo{ + {Name: "teai"}, + {Name: "colony-tick-demo", Empty: true}, + } + fc.issues["alterminal/colony-tick-demo"] = []Issue{ + { + Number: 1, Title: "初始化項目", UpdatedAt: "2026-09-08T00:00:00Z", + Assignees: []User{*mkUser("alex")}, + Repository: &Repository{FullName: "alterminal/colony-tick-demo"}, + HTMLURL: "https://gitea.alterminal.com/alterminal/colony-tick-demo/issues/1", + }, + } + work, err := s.Next() + if err != nil { + t.Fatal(err) + } + if work == nil || work.Type != "issue" || work.Number != 1 || work.Repo != "alterminal/colony-tick-demo" { + t.Errorf("應拾取空倉庫中的 issue #1,得到 %+v", work) + } +} + +// TestMineIncludesEmptyRepoIssues 回歸測試(#43):mine 同樣不因倉庫為空而漏列。 +func TestMineIncludesEmptyRepoIssues(t *testing.T) { + s, fc := newTestScanner() + fc.repos["alterminal"] = []Repo{ + {Name: "teai"}, + {Name: "colony-tick-demo", Empty: true}, + } + fc.issues["alterminal/colony-tick-demo"] = []Issue{ + {Number: 1, Title: "初始化項目", UpdatedAt: "2026-09-08T00:00:00Z", Assignees: []User{*mkUser("alex")}}, + } + issues, err := s.Mine() + if err != nil { + t.Fatal(err) + } + if len(issues) != 1 || issues[0].Num() != 1 { + t.Errorf("mine 應列出空倉庫中的 issue #1,得到 %d 件", len(issues)) + } +} + func TestNextNone(t *testing.T) { s, _ := newTestScanner() work, err := s.Next()