milestones:新增跨倉庫里程碑總覽命令(#31)
- teai milestones(不帶 --repo)輸出跨所屬組織各倉庫 open 里程碑概況, 對應 gitea.py milestones(管理者巡邏,agents AGENTS.md 10.1): 欄位 repo/id/title/url/open_issues/closed_issues/due_on/due_hours/ overdue/unassigned/updated_at,排序期限近者在前、無期限最後。 - internal/workflow.MilestoneOverview:判定核心(Source 注入、離線可測); MilestoneEntry 自訂 MarshalJSON,鍵集鍵序與 gitea.py 全等 (null 表示、due_hours 定點一位、unassigned PR 條目帶 author)。 - internal/workflow.APIClient 增 OpenMilestones/MilestoneOpenIssues (issues 端點刻意不帶 type=issues,PR 條目保留供覆蓋檢查,同 gitea.py)。 - milestones --repo a/b 維持現行單倉庫 list 語義不變。 - 空清單輸出 [](gitea.py 無輸出;#26 慣例差異,README 已文件化)。 - 交叉驗證:同帳號同時跑 gitea.py milestones 與 teai milestones, 含逾期/未到期/無期限里程碑與未分派 issue/PR 條目,輸出位元組全等。
This commit is contained in:
@@ -173,5 +173,39 @@ func (a *APIClient) IssueComments(owner, repo string, number int64) ([]Comment,
|
||||
return a.ListComments(owner, repo, number)
|
||||
}
|
||||
|
||||
// 編譯期確認 APIClient 同時實作 Client 與 StalledSource。
|
||||
// ── MilestoneSource 面向(#31 跨倉庫里程碑總覽)────────────────────────
|
||||
// APIClient 在 StalledSource 之外另實作 MilestoneSource,讓 milestones
|
||||
// 總覽命令與既有命令共用同一個 HTTP 用戶端;查詢參數對照 gitea.py 的
|
||||
// list_open_milestones_for_repository/_milestone_open_issues。
|
||||
|
||||
// OpenMilestones 回傳倉庫的 open 里程碑(GET /repos/{o}/{r}/milestones?state=open)。
|
||||
func (a *APIClient) OpenMilestones(owner, repo string) ([]Milestone, error) {
|
||||
var ms []Milestone
|
||||
path := "/repos/" + url.PathEscape(owner) + "/" + url.PathEscape(repo) + "/milestones"
|
||||
opts := gitea.ListOptions{Extra: url.Values{"state": {"open"}}}
|
||||
if err := a.Client.ListAll(context.Background(), path, opts, &ms); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ms, nil
|
||||
}
|
||||
|
||||
// MilestoneOpenIssues 回傳掛在指定里程碑(依名稱過濾,Gitea 以
|
||||
// milestones=<title> 查詢)的 open 條目。刻意**不**帶 type=issues——
|
||||
// PR 亦屬里程碑條目,保留兩者供覆蓋檢查(同 gitea.py
|
||||
// _milestone_open_issues;PR 帶 pull_request 標記由 workflow 判別)。
|
||||
func (a *APIClient) MilestoneOpenIssues(owner, repo, milestoneTitle string) ([]Issue, error) {
|
||||
var issues []Issue
|
||||
path := "/repos/" + url.PathEscape(owner) + "/" + url.PathEscape(repo) + "/issues"
|
||||
opts := gitea.ListOptions{Extra: url.Values{
|
||||
"state": {"open"},
|
||||
"milestones": {milestoneTitle},
|
||||
}}
|
||||
if err := a.Client.ListAll(context.Background(), path, opts, &issues); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return issues, nil
|
||||
}
|
||||
|
||||
// 編譯期確認 APIClient 同時實作 Client、StalledSource 與 MilestoneSource。
|
||||
var _ StalledSource = (*APIClient)(nil)
|
||||
var _ MilestoneSource = (*APIClient)(nil)
|
||||
|
||||
Reference in New Issue
Block a user