fix(git): handle file renames between folders (#6020)

* git storage: handle file renames between folders

---------

Co-authored-by: Nicolas Giard <github@ngpixel.com>
This commit is contained in:
Eric Knibbe
2023-01-29 23:09:33 -05:00
committed by GitHub
parent 8fa771c4ce
commit 2e8585478f
4 changed files with 23 additions and 8 deletions

View File

@@ -725,7 +725,7 @@ module.exports = class Page extends Model {
const destinationHash = pageHelper.generateHash({ path: opts.destinationPath, locale: opts.destinationLocale, privateNS: opts.isPrivate ? 'TODO' : '' })
// -> Move page
const destinationTitle = (page.title === page.path ? opts.destinationPath : page.title)
const destinationTitle = (page.title === _.last(page.path.split('/')) ? _.last(opts.destinationPath.split('/')) : page.title)
await WIKI.models.pages.query().patch({
path: opts.destinationPath,
localeCode: opts.destinationLocale,
@@ -745,6 +745,7 @@ module.exports = class Page extends Model {
...page,
destinationPath: opts.destinationPath,
destinationLocaleCode: opts.destinationLocale,
title: destinationTitle,
destinationHash
})