From 0ff25b755233b3cfa093cf66c0bae392c4be492c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Sat, 29 Jul 2023 14:41:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/other/update.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/plugins/other/update.js b/plugins/other/update.js index dd1145d..0c92dee 100644 --- a/plugins/other/update.js +++ b/plugins/other/update.js @@ -87,9 +87,7 @@ export class update extends plugin { type = '强制更新' cm = `git reset --hard && git pull --rebase --allow-unrelated-histories` } - - if (plugin) - cm = `cd "plugins/${plugin}" && ${cm}` + if (plugin) cm = `cd "plugins/${plugin}" && ${cm}` this.oldCommitId = await this.getcommitId(plugin) @@ -122,8 +120,7 @@ export class update extends plugin { async getcommitId(plugin = '') { let cm = 'git rev-parse --short HEAD' - if (plugin) - cm = `cd "plugins/${plugin}" && git rev-parse --short HEAD` + if (plugin) cm = `cd "plugins/${plugin}" && ${cm}` const commitId = await execSync(cm, { encoding: 'utf-8' }) return lodash.trim(commitId) @@ -131,8 +128,7 @@ export class update extends plugin { async getTime(plugin = '') { let cm = 'git log -1 --pretty=format:"%cd" --date=format:"%F %T"' - if (plugin) - cm = `cd "plugins/${plugin}" && git log -1 --pretty=format:"%cd" --date=format:"%F %T"` + if (plugin) cm = `cd "plugins/${plugin}" && ${cm}` let time = '' try { @@ -196,8 +192,7 @@ export class update extends plugin { async getLog(plugin = '') { let cm = 'git log -100 --pretty=format:"%h||[%cd] %s" --date=format:"%F %T"' - if (plugin) - cm = `cd "plugins/${plugin}" && ${cm}` + if (plugin) cm = `cd "plugins/${plugin}" && ${cm}` let logAll try { @@ -219,14 +214,16 @@ export class update extends plugin { log.push(str[1]) } let line = log.length - log = log.join('\n') + log = log.join('\n\n') if (log.length <= 0) return '' let end = '' try { - end = await execSync('git config -l', { encoding: 'utf-8' }) - end = end.match(/remote\..*\.url=.+/g).join('\n').replace(/remote\..*\.url=/g, '') + cm = 'git config -l' + if (plugin) cm = `cd "plugins/${plugin}" && ${cm}` + end = await execSync(cm, { encoding: 'utf-8' }) + end = end.match(/remote\..*\.url=.+/g).join('\n\n').replace(/remote\..*\.url=/g, '') } catch (error) { logger.error(error.toString()) await this.reply(error.toString())