Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
2e858547
Unverified
Commit
2e858547
authored
Jan 29, 2023
by
Eric Knibbe
Committed by
GitHub
Jan 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(git): handle file renames between folders (#6020)
* git storage: handle file renames between folders --------- Co-authored-by:
Nicolas Giard
<
github@ngpixel.com
>
parent
8fa771c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
8 deletions
+23
-8
db.js
server/core/db.js
+1
-1
pages.js
server/models/pages.js
+2
-1
storage.js
server/modules/storage/disk/storage.js
+1
-1
storage.js
server/modules/storage/git/storage.js
+19
-5
No files found.
server/core/db.js
View file @
2e858547
...
@@ -138,7 +138,7 @@ module.exports = {
...
@@ -138,7 +138,7 @@ module.exports = {
switch
(
WIKI
.
config
.
db
.
type
)
{
switch
(
WIKI
.
config
.
db
.
type
)
{
case
'postgres'
:
case
'postgres'
:
await
conn
.
query
(
`set application_name = 'Wiki.js'`
)
await
conn
.
query
(
`set application_name = 'Wiki.js'`
)
// -> Set schema if it's not public
// -> Set schema if it's not public
if
(
WIKI
.
config
.
db
.
schema
&&
WIKI
.
config
.
db
.
schema
!==
'public'
)
{
if
(
WIKI
.
config
.
db
.
schema
&&
WIKI
.
config
.
db
.
schema
!==
'public'
)
{
await
conn
.
query
(
`set search_path TO
${
WIKI
.
config
.
db
.
schema
}
, public;`
)
await
conn
.
query
(
`set search_path TO
${
WIKI
.
config
.
db
.
schema
}
, public;`
)
}
}
...
...
server/models/pages.js
View file @
2e858547
...
@@ -725,7 +725,7 @@ module.exports = class Page extends Model {
...
@@ -725,7 +725,7 @@ module.exports = class Page extends Model {
const
destinationHash
=
pageHelper
.
generateHash
({
path
:
opts
.
destinationPath
,
locale
:
opts
.
destinationLocale
,
privateNS
:
opts
.
isPrivate
?
'TODO'
:
''
})
const
destinationHash
=
pageHelper
.
generateHash
({
path
:
opts
.
destinationPath
,
locale
:
opts
.
destinationLocale
,
privateNS
:
opts
.
isPrivate
?
'TODO'
:
''
})
// -> Move page
// -> 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
({
await
WIKI
.
models
.
pages
.
query
().
patch
({
path
:
opts
.
destinationPath
,
path
:
opts
.
destinationPath
,
localeCode
:
opts
.
destinationLocale
,
localeCode
:
opts
.
destinationLocale
,
...
@@ -745,6 +745,7 @@ module.exports = class Page extends Model {
...
@@ -745,6 +745,7 @@ module.exports = class Page extends Model {
...
page
,
...
page
,
destinationPath
:
opts
.
destinationPath
,
destinationPath
:
opts
.
destinationPath
,
destinationLocaleCode
:
opts
.
destinationLocale
,
destinationLocaleCode
:
opts
.
destinationLocale
,
title
:
destinationTitle
,
destinationHash
destinationHash
})
})
...
...
server/modules/storage/disk/storage.js
View file @
2e858547
...
@@ -135,7 +135,7 @@ module.exports = {
...
@@ -135,7 +135,7 @@ module.exports = {
transform
:
async
(
page
,
enc
,
cb
)
=>
{
transform
:
async
(
page
,
enc
,
cb
)
=>
{
const
pageObject
=
await
WIKI
.
models
.
pages
.
query
().
findById
(
page
.
id
)
const
pageObject
=
await
WIKI
.
models
.
pages
.
query
().
findById
(
page
.
id
)
page
.
tags
=
await
pageObject
.
$relatedQuery
(
'tags'
)
page
.
tags
=
await
pageObject
.
$relatedQuery
(
'tags'
)
let
fileName
=
`
${
page
.
path
}
.
${
pageHelper
.
getFileExtension
(
page
.
contentType
)}
`
let
fileName
=
`
${
page
.
path
}
.
${
pageHelper
.
getFileExtension
(
page
.
contentType
)}
`
if
(
WIKI
.
config
.
lang
.
code
!==
page
.
localeCode
)
{
if
(
WIKI
.
config
.
lang
.
code
!==
page
.
localeCode
)
{
fileName
=
`
${
page
.
localeCode
}
/
${
fileName
}
`
fileName
=
`
${
page
.
localeCode
}
/
${
fileName
}
`
...
...
server/modules/storage/git/storage.js
View file @
2e858547
...
@@ -146,10 +146,24 @@ module.exports = {
...
@@ -146,10 +146,24 @@ module.exports = {
const
diff
=
await
this
.
git
.
diffSummary
([
'-M'
,
currentCommitLog
.
hash
,
latestCommitLog
.
hash
])
const
diff
=
await
this
.
git
.
diffSummary
([
'-M'
,
currentCommitLog
.
hash
,
latestCommitLog
.
hash
])
if
(
_
.
get
(
diff
,
'files'
,
[]).
length
>
0
)
{
if
(
_
.
get
(
diff
,
'files'
,
[]).
length
>
0
)
{
let
filesToProcess
=
[]
let
filesToProcess
=
[]
const
filePattern
=
/
(
.*
?)(?:
{
(
.*
?))?
=>
(?:(
.*
?)
}
)?(
.*
)
/
for
(
const
f
of
diff
.
files
)
{
for
(
const
f
of
diff
.
files
)
{
const
fMoved
=
f
.
file
.
split
(
' => '
)
const
fMatch
=
f
.
file
.
match
(
filePattern
)
const
fName
=
fMoved
.
length
===
2
?
fMoved
[
1
]
:
fMoved
[
0
]
const
fNames
=
{
const
fPath
=
path
.
join
(
this
.
repoPath
,
fName
)
old
:
null
,
new
:
null
}
if
(
!
fMatch
)
{
fNames
.
old
=
f
.
file
fNames
.
new
=
f
.
file
}
else
if
(
!
fMatch
[
2
]
&&
!
fMatch
[
3
])
{
fNames
.
old
=
fMatch
[
1
]
fNames
.
new
=
fMatch
[
4
]
}
else
{
fNames
.
old
=
(
fMatch
[
1
]
+
fMatch
[
2
]
+
fMatch
[
4
]).
replace
(
'//'
,
'/'
),
fNames
.
new
=
(
fMatch
[
1
]
+
fMatch
[
3
]
+
fMatch
[
4
]).
replace
(
'//'
,
'/'
)
}
const
fPath
=
path
.
join
(
this
.
repoPath
,
fNames
.
new
)
let
fStats
=
{
size
:
0
}
let
fStats
=
{
size
:
0
}
try
{
try
{
fStats
=
await
fs
.
stat
(
fPath
)
fStats
=
await
fs
.
stat
(
fPath
)
...
@@ -166,8 +180,8 @@ module.exports = {
...
@@ -166,8 +180,8 @@ module.exports = {
path
:
fPath
,
path
:
fPath
,
stats
:
fStats
stats
:
fStats
},
},
oldPath
:
f
Moved
[
0
]
,
oldPath
:
f
Names
.
old
,
relPath
:
fName
relPath
:
fName
s
.
new
})
})
}
}
await
this
.
processFiles
(
filesToProcess
,
rootUser
)
await
this
.
processFiles
(
filesToProcess
,
rootUser
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment