refactor(標籤): 把列標籤抽到 lib,讓要貼標籤的腳本共用

labels-list 與後續要挑標籤的腳本都要打同一個端點,抽成 lib.listLabels 之後
端點只寫在一個地方。順帶把「本專案不建立標籤,這是取得標籤的唯一途徑」寫進
函式註解,讓下一個要加功能的人先看到這條界線。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-17 04:44:45 +00:00
co-authored by Claude Opus 5
parent d417132b4e
commit 4f542d9c86
2 changed files with 17 additions and 3 deletions
+15
View File
@@ -418,6 +418,21 @@ function checkTimeTracker(info) {
}
}
// ── 標籤 ───────────────────────────────────────────────────────────
/**
* 取得 repo 上的既有標籤。
* 本專案不建立標籤,所以這是取得標籤的唯一途徑:要貼標籤的腳本先從這裡拿清單,
* 挑不到合適的就不貼。
* @param {{base: string, token: string}} login
* @param {string} repo owner/name
* @returns {Promise<object[]>}
*/
export async function listLabels(login, repo) {
const path = `/repos/${repo}/labels`;
return expectOk(await giteaRequest(login, 'GET', path), `GET ${path}`) ?? [];
}
// ── 冪等查重 ───────────────────────────────────────────────────────
/**