From 566043ec4353bfc5188f1ee45fc76a68ae4422db Mon Sep 17 00:00:00 2001 From: NGPixel Date: Fri, 24 Apr 2020 20:30:08 -0400 Subject: [PATCH] fix: perform git move manually to prevent bad source --- server/modules/storage/git/storage.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/modules/storage/git/storage.js b/server/modules/storage/git/storage.js index 3fd7e313..d0be00bb 100644 --- a/server/modules/storage/git/storage.js +++ b/server/modules/storage/git/storage.js @@ -302,19 +302,24 @@ module.exports = { */ async renamed(page) { WIKI.logger.info(`(STORAGE/GIT) Committing file move from [${page.localeCode}] ${page.path} to [${page.destinationLocaleCode}] ${page.destinationPath}...`) - let sourceFilePath = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` - let destinationFilePath = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}` + let sourceFileName = `${page.path}.${pageHelper.getFileExtension(page.contentType)}` + let destinationFileName = `${page.destinationPath}.${pageHelper.getFileExtension(page.contentType)}` if (WIKI.config.lang.namespacing) { if (WIKI.config.lang.code !== page.localeCode) { - sourceFilePath = `${page.localeCode}/${sourceFilePath}` + sourceFileName = `${page.localeCode}/${sourceFileName}` } if (WIKI.config.lang.code !== page.destinationLocaleCode) { - destinationFilePath = `${page.destinationLocaleCode}/${destinationFilePath}` + destinationFileName = `${page.destinationLocaleCode}/${destinationFileName}` } } - await this.git.mv(`./${sourceFilePath}`, `./${destinationFilePath}`) + const sourceFilePath = path.join(this.repoPath, sourceFileName) + const destinationFilePath = path.join(this.repoPath, destinationFileName) + await fs.move(sourceFilePath, destinationFilePath) + + await this.git.rm(`./${sourceFileName}`) + await this.git.add(`./${destinationFileName}`) await this.git.commit(`docs: rename ${page.path} to ${page.destinationPath}`, [sourceFilePath, destinationFilePath], { '--author': `"${page.moveAuthorName} <${page.moveAuthorEmail}>"` })