cli:修正帶旗標命令被全域剖析攔下的阻斷問題(#13 審核)
- parseGlobals 改為抽取式 extractGlobals:只取走已知全域選項,非全域 選項(--has-work/--mine/--reviewer/--repo)原樣交回子命令 flagset, 任何順序(含與全域選項交錯)皆可解析;-- 之後停止抽取。 - runVersion 補參數檢查:version --wat 仍回 exit 2。 - workflow:commentsFor 對 number<=0 視為無留言,不打 API(對齊 gitea.py 在 number 缺漏時跳過留言檢查,避免 issues/0/comments 404 中斷掃描)。 - 新增 internal/cli/workflow_commands_test.go:以注入假 client 的接線層 測試補上 workflow 單元測試覆蓋不到的分派路徑(members --has-work、 pulls --mine/--reviewer/--repo、全域選項交錯、next null/table)。 - README:註明與 gitea.py 的已知輸出差異(空清單 [] vs 無輸出; 全域選項可出現在命令前後)。 實機交叉驗證(alex):members --has-work、pulls --mine/--reviewer、 pulls --repo、next、mine 兩者輸出一致;go vet/test 全綠。
This commit is contained in:
@@ -198,6 +198,16 @@ type orgIssue struct {
|
||||
Issue Issue
|
||||
}
|
||||
|
||||
// commentsFor 取回 issue/PR 的留言;number 缺漏(0)時直接視為無留言,
|
||||
// 不打 API(gitea.py 在 number 為 None 時跳過留言檢查的語義——
|
||||
// 避免拿 0 去 issues/0/comments 觸發 404 中斷整個掃描)。
|
||||
func (s *Scanner) commentsFor(owner, repo string, number int64) ([]Comment, error) {
|
||||
if number <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return s.Client.ListComments(owner, repo, number)
|
||||
}
|
||||
|
||||
// collectMemberIssues 跨組織收集分派給 members(至少一人)且最後一則留言
|
||||
// 不是 assignee 的 open issues(gitea.py 的 for_all_organizations)。
|
||||
func (s *Scanner) collectMemberIssues(members []string) ([]orgIssue, error) {
|
||||
@@ -217,7 +227,7 @@ func (s *Scanner) collectMemberIssues(members []string) ([]orgIssue, error) {
|
||||
if !AssigneeOverlaps(issue, members) {
|
||||
continue
|
||||
}
|
||||
comments, err := s.Client.ListComments(owner, repo, issue.issueNumber())
|
||||
comments, err := s.commentsFor(owner, repo, issue.issueNumber())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -275,7 +285,7 @@ func (s *Scanner) Pulls(mine, reviewer bool) ([]PullItem, error) {
|
||||
for _, rp := range repoPulls {
|
||||
for i := range rp.Pulls {
|
||||
pr := &rp.Pulls[i]
|
||||
comments, err := s.Client.ListComments(rp.Owner, rp.Repo, pr.Number)
|
||||
comments, err := s.commentsFor(rp.Owner, rp.Repo, pr.Number)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -331,7 +341,7 @@ func (s *Scanner) usernamesWithUnfinishedWork(members []string) (map[string]bool
|
||||
for _, rp := range repoPulls {
|
||||
for i := range rp.Pulls {
|
||||
pr := &rp.Pulls[i]
|
||||
comments, err := s.Client.ListComments(rp.Owner, rp.Repo, pr.Number)
|
||||
comments, err := s.commentsFor(rp.Owner, rp.Repo, pr.Number)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user