From aeb981dca06d722068fac50df463eada7d6f8eb3 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Thu, 28 May 2026 14:43:45 +0800 Subject: [PATCH] Limit asset registry scan to tracked files --- utils/asset-registry.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/asset-registry.ts b/utils/asset-registry.ts index 08bf035..7574a4c 100644 --- a/utils/asset-registry.ts +++ b/utils/asset-registry.ts @@ -1,3 +1,4 @@ +import { execFileSync } from 'node:child_process' import { createHash } from 'node:crypto' import { existsSync, readdirSync, readFileSync } from 'node:fs' import path from 'node:path' @@ -69,6 +70,14 @@ export function expandAssetRegistry(manifest = loadAssetRegistry()): AssetRegist } export function listTargetBinaryAssets(rootDir = repoRoot): string[] { + const trackedAssets = listTrackedRepoFiles(rootDir) + + if (trackedAssets) { + return trackedAssets + .filter(repoPath => targetAssetExtensions.has(path.extname(repoPath).toLowerCase())) + .sort((a, b) => a.localeCompare(b)) + } + const assets: string[] = [] function visit(directory: string) { @@ -130,6 +139,17 @@ function isIgnoredDirectory(repoPath: string): boolean { }) } +function listTrackedRepoFiles(rootDir: string): string[] | undefined { + try { + return execFileSync('git', ['-C', rootDir, 'ls-files', '-z'], { encoding: 'utf8' }) + .split('\0') + .filter(Boolean) + } + catch { + return undefined + } +} + function toRepoPath(absolutePath: string, rootDir: string): string { return path.relative(rootDir, absolutePath).split(path.sep).join('/') }