优化 更新
This commit is contained in:
parent
090b7d8b43
commit
0ff25b7552
|
@ -87,9 +87,7 @@ export class update extends plugin {
|
||||||
type = '强制更新'
|
type = '强制更新'
|
||||||
cm = `git reset --hard && git pull --rebase --allow-unrelated-histories`
|
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)
|
this.oldCommitId = await this.getcommitId(plugin)
|
||||||
|
|
||||||
|
@ -122,8 +120,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 = `cd "plugins/${plugin}" && ${cm}`
|
||||||
cm = `cd "plugins/${plugin}" && git rev-parse --short HEAD`
|
|
||||||
|
|
||||||
const commitId = await execSync(cm, { encoding: 'utf-8' })
|
const commitId = await execSync(cm, { encoding: 'utf-8' })
|
||||||
return lodash.trim(commitId)
|
return lodash.trim(commitId)
|
||||||
|
@ -131,8 +128,7 @@ export class update extends plugin {
|
||||||
|
|
||||||
async getTime(plugin = '') {
|
async getTime(plugin = '') {
|
||||||
let cm = 'git log -1 --pretty=format:"%cd" --date=format:"%F %T"'
|
let cm = 'git log -1 --pretty=format:"%cd" --date=format:"%F %T"'
|
||||||
if (plugin)
|
if (plugin) cm = `cd "plugins/${plugin}" && ${cm}`
|
||||||
cm = `cd "plugins/${plugin}" && git log -1 --pretty=format:"%cd" --date=format:"%F %T"`
|
|
||||||
|
|
||||||
let time = ''
|
let time = ''
|
||||||
try {
|
try {
|
||||||
|
@ -196,8 +192,7 @@ export class update extends plugin {
|
||||||
|
|
||||||
async getLog(plugin = '') {
|
async getLog(plugin = '') {
|
||||||
let cm = 'git log -100 --pretty=format:"%h||[%cd] %s" --date=format:"%F %T"'
|
let cm = 'git log -100 --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
|
||||||
try {
|
try {
|
||||||
|
@ -219,14 +214,16 @@ export class update extends plugin {
|
||||||
log.push(str[1])
|
log.push(str[1])
|
||||||
}
|
}
|
||||||
let line = log.length
|
let line = log.length
|
||||||
log = log.join('\n')
|
log = log.join('\n\n')
|
||||||
|
|
||||||
if (log.length <= 0) return ''
|
if (log.length <= 0) return ''
|
||||||
|
|
||||||
let end = ''
|
let end = ''
|
||||||
try {
|
try {
|
||||||
end = await execSync('git config -l', { encoding: 'utf-8' })
|
cm = 'git config -l'
|
||||||
end = end.match(/remote\..*\.url=.+/g).join('\n').replace(/remote\..*\.url=/g, '')
|
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) {
|
} catch (error) {
|
||||||
logger.error(error.toString())
|
logger.error(error.toString())
|
||||||
await this.reply(error.toString())
|
await this.reply(error.toString())
|
||||||
|
|
Loading…
Reference in New Issue