62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import type { FileChange } from './types'
|
|
|
|
/**
|
|
* Build a formatted commit message based on the upload context.
|
|
*
|
|
* Symbols:
|
|
* - ✅ = new file
|
|
* - 🔄 = modified file
|
|
* - ❌ = deleted file
|
|
* - Unchanged files are omitted entirely
|
|
*/
|
|
export function buildCommitMessage(
|
|
folderName: string,
|
|
modelFilename: string,
|
|
textureNames: string[],
|
|
compressed: boolean,
|
|
isReplace: boolean,
|
|
fileChanges: Map<string, FileChange>,
|
|
deletedFileNames: string[],
|
|
): string {
|
|
const title = isReplace
|
|
? `update: upload-gltf update -> ${folderName}`
|
|
: `update: upload-gltf add a new model -> ${folderName}`
|
|
|
|
const lines: string[] = [title, '']
|
|
|
|
// Model section — show status for new, changed, or unchanged
|
|
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)' : ''}`)
|
|
} else if (modelChange === 'unchanged') {
|
|
lines.push('📦 Model')
|
|
lines.push(` ↔️ ${modelFilename} (inchange)`)
|
|
}
|
|
|
|
const textureLines: string[] = []
|
|
|
|
for (const textureName of textureNames) {
|
|
const change = fileChanges.get(textureName.toLowerCase())
|
|
if (change === 'new') {
|
|
textureLines.push(` ✅ ${textureName}`)
|
|
} else if (change === 'changed') {
|
|
textureLines.push(` 🔄 ${textureName}`)
|
|
}
|
|
}
|
|
|
|
for (const name of deletedFileNames) {
|
|
textureLines.push(` ❌ ${name} (supprime)`)
|
|
}
|
|
|
|
if (textureLines.length > 0) {
|
|
lines.push('🎨 Textures')
|
|
lines.push(...textureLines)
|
|
}
|
|
|
|
return lines.join('\n')
|
|
}
|