import { REQUIRED_TEXTURES } from './constants' import type { FileChange } from './types' /** * Build a formatted commit message based on the upload context. * * Symbols: * - ✅ = new file * - 🔄 = modified file * - ❌ = missing texture (new upload) or deleted file (update) * - Unchanged files are omitted entirely */ export function buildCommitMessage( folderName: string, destination: string, modelFilename: string, textureNames: string[], compressed: boolean, isReplace: boolean, fileChanges: Map, deletedFileNames: string[], ): string { const title = isReplace ? `update: upload-gltf update -> ${destination}/${folderName}` : `update: upload-gltf add a new model -> ${destination}/${folderName}` const lines: string[] = [title, ''] // Model section — only show if changed or new const modelChange = fileChanges.get(modelFilename.toLowerCase()) if (modelChange === 'new') { lines.push('📦 Model') lines.push(` ✅ ${modelFilename}${compressed ? ' (compressed)' : ''}`) } else if (modelChange === 'changed') { lines.push('📦 Model') lines.push(` 🔄 ${modelFilename}${compressed ? ' (compressed)' : ''}`) } // Textures section — only show lines that have changes const foundTextures = new Set( textureNames.map((t) => t.toLowerCase().replace(/\.[^.]+$/, '')), ) const textureLines: string[] = [] for (const tex of REQUIRED_TEXTURES) { if (foundTextures.has(tex)) { const actual = textureNames.find( (t) => t.toLowerCase().replace(/\.[^.]+$/, '') === tex, )! const change = fileChanges.get(actual.toLowerCase()) if (change === 'new') { textureLines.push(` ✅ ${actual}`) } else if (change === 'changed') { textureLines.push(` 🔄 ${actual}`) } } else if (!isReplace) { textureLines.push(` ❌ ${tex} (manquant)`) } } for (const name of deletedFileNames) { textureLines.push(` ❌ ${name} (supprime)`) } if (textureLines.length > 0) { lines.push('🎨 Textures') lines.push(...textureLines) } return lines.join('\n') }