refactor(release-cleanup): 將清理邏輯由 bash 改寫為 Node.js #6
+4
-2
@@ -18,10 +18,12 @@ export function categorizeTags(tags, releaseTagNames) {
|
||||
const keep = new Set(releaseTagNames)
|
||||
|
||||
return tags.map((tag) => {
|
||||
if (isEmptyOrNull(tag.name)) {
|
||||
// 防禦 null/非物件 tag 與非字串 name:一律歸為 skip,避免後續存取或比對時出錯。
|
||||
const name = tag?.name
|
||||
if (typeof name !== 'string' || isEmptyOrNull(name)) {
|
||||
return { tag, action: 'skip' }
|
||||
}
|
||||
|
Ghost marked this conversation as resolved
|
||||
if (keep.has(tag.name)) {
|
||||
if (keep.has(name)) {
|
||||
return { tag, action: 'keep' }
|
||||
}
|
||||
return { tag, action: 'delete' }
|
||||
|
||||
Reference in New Issue
Block a user
嚴重等級:🟡 警告
審查員:Mage
問題:categorizeTags 函式中直接呼叫 keep.has(tag.name),若 API 回傳的 tag 物件缺少 name 欄位或 name 為非字串,可能導致非預期行為。
建議:增加明確的型別檢查,確保 tag.name 為 string 後再進行比對。