From 538b16382765c7ba3b45bca01fba7e8f7bf4881b Mon Sep 17 00:00:00 2001 From: Jamie Slome Date: Fri, 10 May 2024 09:51:31 +0100 Subject: [PATCH] chore: clear local bare clone immediately after diff generation #550 --- src/proxy/chain.js | 1 + .../processors/push-action/clearBareClone.js | 20 +++++++++++++++++++ src/proxy/processors/push-action/index.js | 1 + 3 files changed, 22 insertions(+) create mode 100644 src/proxy/processors/push-action/clearBareClone.js diff --git a/src/proxy/chain.js b/src/proxy/chain.js index 68982eef..c389a989 100644 --- a/src/proxy/chain.js +++ b/src/proxy/chain.js @@ -11,6 +11,7 @@ const pushActionChain = [ proc.push.pullRemote, proc.push.writePack, proc.push.getDiff, + proc.push.clearBareClone, proc.push.scanDiff, proc.push.blockForAuth, ]; diff --git a/src/proxy/processors/push-action/clearBareClone.js b/src/proxy/processors/push-action/clearBareClone.js new file mode 100644 index 00000000..dfda43eb --- /dev/null +++ b/src/proxy/processors/push-action/clearBareClone.js @@ -0,0 +1,20 @@ +const Step = require('../../actions').Step; +const fs = require('node:fs'); + +const exec = async (req, action) => { + const step = new Step('clearBareClone'); + + // Recursively remove the contents of ./.remote and ignore exceptions + fs.rm('./.remote', { recursive: true, force: true }, (err) => { + if (err) { + throw err; + } + console.log(`.remote is deleted!`); + }); + + action.addStep(step); + return action; +}; + +exec.displayName = 'clearBareClone.exec'; +exports.exec = exec; diff --git a/src/proxy/processors/push-action/index.js b/src/proxy/processors/push-action/index.js index 309b82cd..72a97b33 100644 --- a/src/proxy/processors/push-action/index.js +++ b/src/proxy/processors/push-action/index.js @@ -10,3 +10,4 @@ exports.checkIfWaitingAuth = require('./checkIfWaitingAuth').exec; exports.checkCommitMessages = require('./checkCommitMessages').exec; exports.checkAuthorEmails = require('./checkAuthorEmails').exec; exports.checkUserPushPermission = require('./checkUserPushPermission').exec; +exports.clearBareClone = require('./clearBareClone').exec;