fix: prevent duplicate uploads and group asset commits

This commit is contained in:
Tom Boullay
2026-04-24 16:58:49 +02:00
parent fe8a6f0f54
commit 53c4c0ed60
15 changed files with 329 additions and 152 deletions
+36 -15
View File
@@ -1,4 +1,6 @@
import type { AssetCategory } from './asset-classification'
import type { FileChange } from './types'
import type { PreparedAssetSummary } from './types'
/**
* Build a formatted commit message based on the upload context.
@@ -12,8 +14,7 @@ import type { FileChange } from './types'
export function buildCommitMessage(
folderName: string,
modelFilename: string,
textureNames: string[],
compressed: boolean,
assetSummaries: PreparedAssetSummary[],
isReplace: boolean,
fileChanges: Map<string, FileChange>,
deletedFileNames: string[],
@@ -25,36 +26,56 @@ export function buildCommitMessage(
const lines: string[] = [title, '']
// Model section — show status for new, changed, or unchanged
const modelSummary = assetSummaries.find((asset) => asset.kind === 'model')
const modelChange = fileChanges.get(modelFilename.toLowerCase())
if (modelChange === 'new') {
lines.push('📦 Model')
lines.push(`${modelFilename}${compressed ? ' (compressed)' : ''}`)
lines.push(`${modelFilename}${modelSummary?.compressed ? ' (compressed)' : ''}`)
} else if (modelChange === 'changed') {
lines.push('📦 Model')
lines.push(` 🔄 ${modelFilename}${compressed ? ' (compressed)' : ''}`)
lines.push(` 🔄 ${modelFilename}${modelSummary?.compressed ? ' (compressed)' : ''}`)
} else if (modelChange === 'unchanged') {
lines.push('📦 Model')
lines.push(` ↔️ ${modelFilename} (inchange)`)
lines.push(` ↔️ ${modelFilename}${modelSummary?.compressed ? ' (compressed)' : ' (inchange)'}`)
}
const textureLines: string[] = []
const grouped = new Map<AssetCategory, string[]>()
for (const textureName of textureNames) {
const change = fileChanges.get(textureName.toLowerCase())
for (const asset of assetSummaries) {
if (asset.kind === 'model' || !asset.category) continue
const change = fileChanges.get(asset.filename.toLowerCase())
if (change === 'new') {
textureLines.push(`${textureName}`)
const current = grouped.get(asset.category) || []
current.push(`${asset.filename}${asset.compressed ? ' (compressed)' : ''}`)
grouped.set(asset.category, current)
} else if (change === 'changed') {
textureLines.push(` 🔄 ${textureName}`)
const current = grouped.get(asset.category) || []
current.push(` 🔄 ${asset.filename}${asset.compressed ? ' (compressed)' : ''}`)
grouped.set(asset.category, current)
}
}
for (const name of deletedFileNames) {
textureLines.push(`${name} (supprime)`)
const sectionTitles: Record<AssetCategory, string> = {
color: '🎨 Textures (color)',
roughness: '🪶 Textures (roughness)',
normal: '🧭 Textures (normal)',
metalness: '🔩 Textures (metalness)',
assets: '🧩 Assets',
}
if (textureLines.length > 0) {
lines.push('🎨 Textures')
lines.push(...textureLines)
for (const category of ['color', 'roughness', 'normal', 'metalness', 'assets'] as const) {
const entries = grouped.get(category)
if (!entries || entries.length === 0) continue
lines.push('')
lines.push(sectionTitles[category])
lines.push(...entries)
}
if (deletedFileNames.length > 0) {
lines.push('')
lines.push('🗑 Deleted')
lines.push(...deletedFileNames.map((name) => `${name}`))
}
return lines.join('\n')