修复无法正确获取文件大小的问题
All checks were successful
Mark stale issues and pull requests / stale (push) Successful in 5s

This commit is contained in:
Asahina Mafuyu
2026-03-05 18:28:38 +08:00
committed by GitHub
parent 4a89996bf0
commit 094b5a57de

View File

@@ -21,6 +21,7 @@ jobs:
const prNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const pr = context.payload.pull_request;
let page = 1;
let oversized = [];
@@ -39,10 +40,20 @@ jobs:
for (const file of files) {
// 只检查新增或修改文件
if (["added", "modified", "renamed", "copied"].includes(file.status)) {
if (file.size > MAX_SIZE) {
oversized.push(`- ${file.filename} (${file.size} bytes)`);
}
if (!["added","modified","renamed","copied"].includes(file.status))
continue;
const content = await github.rest.repos.getContent({
owner: pr.head.repo.owner.login,
repo: pr.head.repo.name,
path: file.filename,
ref: pr.head.sha
});
const size = content.data.size;
if (size > MAX_SIZE) {
oversized.push(`- ${file.filename} (${size} bytes)`);
}
}