修复 Git for Windows 更新报错

This commit is contained in:
🌌 2023-06-28 21:43:31 +08:00
parent a8eede7601
commit ea01dbbe7c
1 changed files with 8 additions and 10 deletions

View File

@ -80,9 +80,7 @@ export class update extends plugin {
if (!plugin) return '' if (!plugin) return ''
} }
let path = `./plugins/${plugin}/.git` if (!fs.existsSync(`plugins/${plugin}/.git`)) return false
if (!fs.existsSync(path)) return false
this.typeName = plugin this.typeName = plugin
return plugin return plugin
@ -109,9 +107,9 @@ export class update extends plugin {
if (plugin) { if (plugin) {
if (type == '强制更新') if (type == '强制更新')
cm = `git -C 'plugins/${plugin}' reset --hard && git -C 'plugins/${plugin}' pull --rebase --allow-unrelated-histories` cm = `cd "plugins/${plugin}" && git reset --hard && git pull --rebase --allow-unrelated-histories`
else else
cm = `git -C 'plugins/${plugin}' pull --no-rebase` cm = `cd "plugins/${plugin}" && git pull --no-rebase`
} }
this.oldCommitId = await this.getcommitId(plugin) this.oldCommitId = await this.getcommitId(plugin)
@ -148,7 +146,7 @@ export class update extends plugin {
async getcommitId (plugin = '') { async getcommitId (plugin = '') {
let cm = 'git rev-parse --short HEAD' let cm = 'git rev-parse --short HEAD'
if (plugin) { if (plugin) {
cm = `git -C ./plugins/${plugin}/ rev-parse --short HEAD` cm = `cd "plugins/${plugin}" && git rev-parse --short HEAD`
} }
let commitId = await execSync(cm, { encoding: 'utf-8' }) let commitId = await execSync(cm, { encoding: 'utf-8' })
@ -158,9 +156,9 @@ export class update extends plugin {
} }
async getTime (plugin = '') { async getTime (plugin = '') {
let cm = 'git log -1 --oneline --pretty=format:"%cd" --date=format:"%m-%d %H:%M"' let cm = 'git log -1 --pretty=format:"%cd" --date=format:"%F %T"'
if (plugin) { if (plugin) {
cm = `cd ./plugins/${plugin}/ && git log -1 --oneline --pretty=format:"%cd" --date=format:"%m-%d %H:%M"` cm = `cd "plugins/${plugin}" && git log -1 --pretty=format:"%cd" --date=format:"%F %T"`
} }
let time = '' let time = ''
@ -228,9 +226,9 @@ export class update extends plugin {
} }
async getLog (plugin = '') { async getLog (plugin = '') {
let cm = 'git log -20 --oneline --pretty=format:"%h||[%cd] %s" --date=format:"%m-%d %H:%M"' let cm = 'git log -20 --pretty=format:"%h||[%cd] %s" --date=format:"%F %T"'
if (plugin) { if (plugin) {
cm = `cd ./plugins/${plugin}/ && ${cm}` cm = `cd "plugins/${plugin}" && ${cm}`
} }
let logAll let logAll