From 693537f1bf9de95602e92f261323060303ce5376 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Wed, 12 Nov 2025 23:14:44 +0100 Subject: [PATCH] upd --- x.js | 115 +++-------------------------------------------------------- 1 file changed, 4 insertions(+), 111 deletions(-) diff --git a/x.js b/x.js index f63b84a..7a4900e 100644 --- a/x.js +++ b/x.js @@ -715,118 +715,11 @@ app.post('/releasehook_kjfhdkf987987', async (req, res) => { const ref = payload.ref || ''; const branchName = ref.replace('refs/heads/', ''); - if (branchName !== targetBranch) { - logMessage(`dashApp push to branch '${branchName}' - skipping version update (only updates on '${targetBranch}' branch)`); - if (!responseSent) { - responseSent = true; - res.status(200).json({ success: true, repository: 'dashApp', message: 'No action taken - not prod branch' }); - } - return; + if (!responseSent) { + responseSent = true; + res.status(200).json({ success: true, repository: 'dashApp', message: 'No action taken - not prod branch' }); } - - logMessage(`dashApp push to ${targetBranch} branch detected - updating version.json`); - - const repoPath = '/home/seb/dash_seedheads_de'; - const versionFilePath = path.join(repoPath, 'version.json'); - - // Function to update version.json and commit changes - const updateVersionFile = async () => { - try { - // Read current version.json - let currentVersion = { v: '0.0.0', d: '' }; - if (fs.existsSync(versionFilePath)) { - const versionContent = fs.readFileSync(versionFilePath, 'utf8'); - try { - currentVersion = JSON.parse(versionContent); - } catch (parseError) { - logMessage(`Error parsing version.json, using defaults: ${parseError.message}`, 'warn'); - } - } else { - logMessage('version.json not found, creating new file with initial version'); - } - - // Increment version number - const versionParts = currentVersion.v.split('.'); - if (versionParts.length >= 3) { - const patch = parseInt(versionParts[2]) || 0; - versionParts[2] = (patch + 1).toString(); - currentVersion.v = versionParts.join('.'); - } else { - // Fallback if version format is unexpected - const lastNum = parseInt(currentVersion.v.replace(/\D/g, '')) || 0; - currentVersion.v = `0.0.${lastNum + 1}`; - } - - // Update date in format YYYYMMDDHHMM - const now = new Date(); - const year = now.getFullYear(); - const month = String(now.getMonth() + 1).padStart(2, '0'); - const day = String(now.getDate()).padStart(2, '0'); - const hour = String(now.getHours()).padStart(2, '0'); - const minute = String(now.getMinutes()).padStart(2, '0'); - currentVersion.d = `${year}${month}${day}${hour}${minute}`; - - // Write updated version.json - const updatedContent = JSON.stringify(currentVersion); - fs.writeFileSync(versionFilePath, updatedContent, 'utf8'); - logMessage(`Updated version.json: ${updatedContent}`); - - // Git commands to commit and push - const gitCommands = [ - `cd ${repoPath}`, - 'git add version.json', - `git commit -m "Auto-update version to ${currentVersion.v} [${currentVersion.d}]"`, - `git push origin ${targetBranch}` - ].join(' && '); - - logMessage(`Executing git commands for dashApp: ${gitCommands}`); - - // Execute git commands - const { stdout: gitOutput, stderr: gitError } = await execCmd(gitCommands, { - cwd: repoPath, - timeoutMs: 30000 - }); - - if (gitOutput) { - logMessage(`Git output for dashApp: ${gitOutput.trim()}`); - } - - if (gitError) { - logMessage(`Git stderr for dashApp: ${gitError.trim()}`, 'warn'); - } - - logMessage(`Successfully updated and pushed version.json for dashApp: v${currentVersion.v}`); - - if (!responseSent) { - responseSent = true; - res.status(200).json({ - success: true, - repository: 'dashApp', - version: currentVersion.v, - date: currentVersion.d, - message: 'Version updated and committed' - }); - } - - } catch (error) { - logMessage(`Error updating version.json for dashApp: ${error.message}`, 'error'); - if (error.stack) { - logMessage(`Stack trace: ${error.stack}`, 'error'); - } - - if (!responseSent) { - responseSent = true; - return res.status(500).json({ - error: 'Version update failed', - details: error.message - }); - } - } - }; - - // Execute the version update - updateVersionFile(); - return; // Exit early to avoid double response + return; } // If we get here, no repository matched