Compare commits

..

No commits in common. "eb0317b533922b32f81259b96d7b47ee832fe9d5" and "3c827be346298bed9273a0a66a2d8d47f753db6b" have entirely different histories.

3 changed files with 47 additions and 74 deletions

View File

@ -617,7 +617,7 @@ async function main(): Promise<void> {
existsSync(uploadedTrackerPath) ? (JSON.parse(readFileSync(uploadedTrackerPath, 'utf8')) as number[]) : [],
)
// Mark the first 35 issues that already had comments posted during Phase 1
for (let i = 0; i < 35; i += 1) {
for (let i = 0; i < entries.length - remaining.length; i += 1) {
commentedIssues.add(entries[i]!.issueNumber)
}
@ -662,9 +662,9 @@ async function main(): Promise<void> {
await postGiteaIssueComment(entry.issueNumber, commentMd)
await closeGiteaIssue(entry.issueNumber)
commentedIssues.add(entry.issueNumber)
writeFileSync(uploadedTrackerPath, JSON.stringify(Array.from(commentedIssues), null, 2))
uploadedCount += 1
if (uploadedCount % 10 === 0 || uploadedCount === toUpload.length) {
if (uploadedCount % 20 === 0 || uploadedCount === toUpload.length) {
writeFileSync(uploadedTrackerPath, JSON.stringify(Array.from(commentedIssues), null, 2))
console.log(` [Gitea Upload+Comment+Close] ${String(uploadedCount)}/${String(toUpload.length)} completed`)
}
}
@ -674,17 +674,13 @@ async function main(): Promise<void> {
writeFileSync(uploadedTrackerPath, JSON.stringify(Array.from(commentedIssues), null, 2))
// Ensure any remaining open issues in Milestone #9 are closed
for (let page = 1; page <= 5; page += 1) {
const openRes = await fetch(`${GITEA_BASE_URL}/issues?state=open&type=issues&milestones=9&limit=50&page=1`, {
const openRes = await fetch(`${GITEA_BASE_URL}/issues?state=open&type=issues&milestones=9&limit=50`, {
headers: { Authorization: `token ${GITEA_TOKEN}` },
signal: AbortSignal.timeout(10000),
})
const openList = (await openRes.json()) as { number: number }[]
if (openList.length === 0) break
for (const iss of openList) {
await closeGiteaIssue(iss.number)
}
}
// Final check on Milestone #9 open/closed count
const msRes = await fetch(`${GITEA_BASE_URL}/milestones/9`, {

View File

@ -27,7 +27,6 @@ export async function uploadPngToGiteaIssue(
const bytes = readFileSync(pngPath)
const fileName = basename(pngPath)
for (let attempt = 1; attempt <= 6; attempt += 1) {
try {
const form = new FormData()
form.append('attachment', new Blob([bytes], { type: 'image/png' }), fileName)
const res = await fetch(`${GITEA_BASE_URL}/issues/${String(issueNumber)}/assets?name=${encodeURIComponent(fileName)}`, {
@ -36,7 +35,6 @@ export async function uploadPngToGiteaIssue(
Authorization: `token ${GITEA_TOKEN}`,
},
body: form,
signal: AbortSignal.timeout(10000),
})
if (res.ok) {
return (await res.json()) as GiteaAssetUploadResult
@ -44,9 +42,6 @@ export async function uploadPngToGiteaIssue(
if (attempt === 6) {
throw new Error(`Failed to upload PNG to issue #${String(issueNumber)}: HTTP ${String(res.status)}`)
}
} catch (err) {
if (attempt === 6) throw err
}
await sleep(250 * attempt)
}
throw new Error('Unreachable')
@ -57,7 +52,6 @@ export async function postGiteaIssueComment(
markdownBody: string,
): Promise<{ id: number; body: string }> {
for (let attempt = 1; attempt <= 6; attempt += 1) {
try {
const res = await fetch(`${GITEA_BASE_URL}/issues/${String(issueNumber)}/comments`, {
method: 'POST',
headers: {
@ -65,7 +59,6 @@ export async function postGiteaIssueComment(
'Content-Type': 'application/json',
},
body: JSON.stringify({ body: markdownBody }),
signal: AbortSignal.timeout(10000),
})
if (res.ok) {
return (await res.json()) as { id: number; body: string }
@ -73,9 +66,6 @@ export async function postGiteaIssueComment(
if (attempt === 6) {
throw new Error(`Failed to post comment on issue #${String(issueNumber)}: HTTP ${String(res.status)}`)
}
} catch (err) {
if (attempt === 6) throw err
}
await sleep(250 * attempt)
}
throw new Error('Unreachable')
@ -83,7 +73,6 @@ export async function postGiteaIssueComment(
export async function closeGiteaIssue(issueNumber: number): Promise<void> {
for (let attempt = 1; attempt <= 6; attempt += 1) {
try {
const res = await fetch(`${GITEA_BASE_URL}/issues/${String(issueNumber)}`, {
method: 'PATCH',
headers: {
@ -91,15 +80,11 @@ export async function closeGiteaIssue(issueNumber: number): Promise<void> {
'Content-Type': 'application/json',
},
body: JSON.stringify({ state: 'closed' }),
signal: AbortSignal.timeout(10000),
})
if (res.ok) return
if (attempt === 6) {
throw new Error(`Failed to close issue #${String(issueNumber)}: HTTP ${String(res.status)}`)
}
} catch (err) {
if (attempt === 6) throw err
}
await sleep(250 * attempt)
}
}

View File

@ -76,14 +76,6 @@ export class UnitStatList {
this.baseStats.set(key, Math.trunc(value))
}
addStat(statNameOrId: string | number, delta: number): void {
const key = this.normalizeStatKey(statNameOrId)
if (key === 'item_allskills') {
this.allSkillsBonus += Math.trunc(delta)
}
this.baseStats.set(key, (this.baseStats.get(key) ?? 0) + Math.trunc(delta))
}
getBaseStat(statNameOrId: string | number): number {
const key = this.normalizeStatKey(statNameOrId)
return this.baseStats.get(key) ?? 0