From f634ec7bba3c105a43e95c68ce6c3f5ec96f4580 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sat, 24 Nov 2018 16:37:26 -0600 Subject: [PATCH] updated docs.patch git handling --- src/server/routes/docs.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/server/routes/docs.js b/src/server/routes/docs.js index 3fe0382..26a9716 100644 --- a/src/server/routes/docs.js +++ b/src/server/routes/docs.js @@ -106,8 +106,7 @@ module.exports = function docs(app) { if (!doc) return notFound(res) if (!isOkDoc({ name: name || doc.name, dir, md }, kb, res)) return let newDir = typeof dir === 'string' ? dir : doc.dir - const oldDir = path.join(docsDir, doc.dir) - const oldPath = path.join(oldDir, doc.name) + const oldPath = path.join(docsDir, doc.dir, doc.name) const docPath = path.join(docsDir, newDir, name || doc.name) const oldRelPath = oldPath.split(docsDir + '/')[1] const curRelPath = docPath.split(docsDir + '/')[1] @@ -125,13 +124,14 @@ module.exports = function docs(app) { } await tryRmdir(docsDir, oldRelPath) - if (useGit && isNewPath) { - await git.rm(oldPath) + if (useGit) { + let commitMsg = `updated doc ${curRelPath}` + if (isNewPath) { + git.rm(oldPath) + commitMsg = `renamed doc ${oldRelPath} to ${curRelPath}` + } await git.add(docPath) - await git.commit(`renamed doc ${oldRelPath} to ${curRelPath}`) - } else if (useGit) { - await git.add(docPath) - await git.commit(`updated doc ${curRelPath}`) + await git.commit(commitMsg) } } catch (err) { return serverError(res, err)