From 9a50124b1090e25638e28e41f9ff2772e248f3d1 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sun, 1 Jun 2025 11:46:59 +0200 Subject: [PATCH] Add script to rewrite commit messages and update gitignore --- main.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.js b/main.js index 758e6c2..d338f7d 100644 --- a/main.js +++ b/main.js @@ -1101,7 +1101,27 @@ function getRandomMessage() { */ // Nutze das Template aus dem Projektordner: +const TEMPLATE_PATH = path.join(__dirname, 'rewrite-commit-msg.js.template'); +function createRewriteScript(mapping) { + // Lies das Template + let content = fs.readFileSync(TEMPLATE_PATH, 'utf-8'); + // Ersetze __MESSAGE_MAP__ durch dein Mapping + content = content.replace('__MESSAGE_MAP__', JSON.stringify(mapping)); + // Speichere als temporäre Datei + const scriptPath = path.join(__dirname, `rewrite-commit-msg.${Date.now()}.js`); + fs.writeFileSync(scriptPath, content, 'utf-8'); + return scriptPath; +} + +function addMatchingFilesToGitignore(folderPath, pattern) { + const files = fs.readdirSync(folderPath); + const matches = micromatch(files, pattern); + for (const file of matches) { + ensureInGitignore(folderPath, pattern); + break; // Nur einmal pro Pattern eintragen + } +} async function autoCommit(folderPath, message, win) {