From eea58515ff4779787a5064567ae65a57cc3a1801 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Wed, 29 Nov 2023 11:55:16 -0500 Subject: [PATCH] Ensure that plugin build hash actually has a git hash to compare with -- otherwise force rebuild. --- client/gulpfile.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/client/gulpfile.js b/client/gulpfile.js index 3f277e71a9d..44a8dfe93dc 100644 --- a/client/gulpfile.js +++ b/client/gulpfile.js @@ -121,21 +121,25 @@ function buildPlugins(callback, forceRebuild) { skipBuild = false; } else { if (fs.existsSync(hashFilePath)) { - skipBuild = - child_process.spawnSync( - "git", - ["diff", "--quiet", `$(cat ${hashFilePath})`, "--", pluginDir], - { + const hashFileContent = fs.readFileSync(hashFilePath, "utf8").trim(); + const isHash = /^[0-9a-f]{7,40}$/.test(hashFileContent); // Check for a 7 to 40 character hexadecimal string + + if (!isHash) { + console.log(`Hash file for ${pluginName} exists but does not have a valid git hash.`); + skipBuild = false; + } else { + skipBuild = + child_process.spawnSync("git", ["diff", "--quiet", hashFileContent, "--", pluginDir], { stdio: "inherit", shell: true, - } - ).status === 0; - if (!skipBuild) { - // Hash exists and is outdated, triggering a rebuild. - // Stage current hash to .orig for debugging and to - // force a plugin rebuild in the event of a failure - // (i.e. -- we're committed to a new build of this plugin). - fs.renameSync(hashFilePath, `${hashFilePath}.orig`); + }).status === 0; + if (!skipBuild) { + // Hash exists and is outdated, triggering a rebuild. + // Stage current hash to .orig for debugging and to + // force a plugin rebuild in the event of a failure + // (i.e. -- we're committed to a new build of this plugin). + fs.renameSync(hashFilePath, `${hashFilePath}.orig`); + } } } else { console.log(`No build hashfile detected for ${pluginName}, generating now.`);