Synchronize the file's committer in the Git repository as the editor of the Wiki page, help! #7274
Unanswered
imysl0
asked this question in
Help / Questions
Replies: 1 comment
-
Modifications in "storage.js". async sync() {
...
const rootUser = await WIKI.models.users.getRootUser()
...
if (_.includes(['sync', 'pull'], this.mode)) {
const latestCommitLog = _.get(await this.git.log(['-n', '1', this.config.branch, '--']), 'latest', {})
const diff = await this.git.diffSummary(['-M', currentCommitLog.hash, latestCommitLog.hash])
if (_.get(diff, 'files', []).length > 0) {
...
const commitLog = _.get(await this.git.log({ file: f }), 'latest', {})
const authorName = commitLog.author_name
const authorEmail = _.toLower(commitLog.author_email)
WIKI.logger.info(`(STORAGE/GIT) name ${authorName} mail ${authorEmail} log ${commitLog}`)
const gitusr = await WIKI.models.users.getUserByEmail(authorEmail)
WIKI.logger.info(`(STORAGE/GIT) permissions ${gitusr.permissions} groups ${gitusr.groups}`)
filesToProcess.push({
...f,
file: {
path: fPath,
stats: fStats
},
oldPath: fNames.old,
relPath: fNames.new,
usr: gitusr
})
}
await this.processFiles(filesToProcess, rootUser)
}
}
},
async processFiles(files, user) {
...
await WIKI.models.pages.movePage({
user: item.usr,
path: contentPath.path,
destinationPath: contentDestinationPath.path,
locale: contentPath.locale,
destinationLocale: contentPath.locale,
skipStorage: true
})
...
await WIKI.models.pages.deletePage({
user: item.usr,
path: contentPath.path,
locale: contentPath.locale,
skipStorage: true
})
continue
}
...
try {
await commonDisk.processPage({
user: item.usr,
relPath: item.relPath,
fullPath: this.repoPath,
contentType: contentType,
moduleName: 'GIT'
})
...
try {
await commonDisk.processAsset({
user: item.usr,
relPath: item.relPath,
file: item.file,
contentType: contentType,
moduleName: 'GIT'
})
} catch (err) {
WIKI.logger.warn(`(STORAGE/GIT) Failed to process asset ${item.relPath}`)
WIKI.logger.warn(err)
}
}
}
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When synchronizing with Wiki and Git, I noticed that the committer on Git cannot be synchronized as the editor of the Wiki page. The editor of the Wiki page is always the administrator.
I modified "server\modules\storage\git\storage.js" to fetch the email from Git's log, with the intention of using this email as the editor for the Wiki page. After some debugging, I still ended up failing. I am not a professional programmer, so I am seeking help. Does anyone know why this might be happening or how it could be done?
My modifications.
in storage.js
The following compressed package contains the "storage.js" I used. I mainly modified the "sync" function and the "processFiles" function. In the "sync" function, I obtained the user's email information, found this user in the Wiki system, and named the variable "gitusr". Then, I placed "gitusr" into "filesToProcess". In the "processFiles" function, I used "gitusr" from "filesToProcess" to handle file changes.
storage.js.gz
in users.js
I added a function.
problems
I suspect the error is being thrown in these two files, but I really don't understand what's going on.
More
Any assistance would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions