🐛 fix(vscode): 修复 PR 上的审查意见没自动转给实施会话
识别审查评论标记和 PR 里 Closes #N 的规则被写坏(多了反斜杠、标记名少了个 s), 审查评论全被当成普通评论丢掉。现在这两条规则只在 gitea/markers.ts 里定义一份, webhook 和评论气泡都调用它,并补上单测,以后写坏会直接测出来。
This commit is contained in:
1 parent
cb540c5db5
commit
858bd1e34b
4 files changed
+105
-11
No files matched your search
@@ -23,6 +23,7 @@ import { detectRepo } from '../git/remote'
|
||||
import { deleteWebhook, getIssue, getPullRequest, listIssueComments } from '../gitea/api'
|
||||
import { systemCommentText } from '../gitea/issueComment'
|
||||
import { loadIssues, loadSingleIssue } from '../gitea/issueLoader'
|
||||
import { hasReviewMarker, parseClosingIssueNumber, stripReviewMarker } from '../gitea/markers'
|
||||
import { hasStateColumn, mergeStateJsonComment, mergeStateJsonCommentGuarded, readStateJsonComment } from '../gitea/stateJson'
|
||||
import { getLocalIssueState, mergeLocalIssueState, overlayLocalIssueState } from '../issues/localState'
|
||||
import { logger } from '../logging/logger'
|
||||
@@ -357,9 +358,8 @@ class WebhookCoordinator {
|
||||
return event.issueNumber
|
||||
|
||||
const body = event.body || ''
|
||||
const m = body.match(/\b(?:closes|fixes|resolves|close|fix|resolve)\s+#(\d+)/i)
|
||||
if (m) {
|
||||
const n = Number.parseInt(m[1], 10)
|
||||
const n = parseClosingIssueNumber(body)
|
||||
if (n !== undefined) {
|
||||
logger.add({
|
||||
level: 'info',
|
||||
source: 'webhook',
|
||||
@@ -1449,9 +1449,9 @@ class WebhookCoordinator {
|
||||
repo: ctx.repo,
|
||||
index: event.prNumber,
|
||||
})
|
||||
const m = (pr.body ?? '').match(/\\b(?:closes|fixes|resolves|close|fix|resolve)\\s+#(\\d+)/i)
|
||||
if (m) {
|
||||
realIssueNumber = Number.parseInt(m[1], 10)
|
||||
const closing = parseClosingIssueNumber(pr.body ?? '')
|
||||
if (closing !== undefined) {
|
||||
realIssueNumber = closing
|
||||
logger.add({
|
||||
level: 'info',
|
||||
source: 'webhook',
|
||||
@@ -1532,7 +1532,7 @@ class WebhookCoordinator {
|
||||
})
|
||||
}
|
||||
|
||||
if (!/<!--\\s+px:review=1\\s*-->/i.test(body)) {
|
||||
if (!hasReviewMarker(body)) {
|
||||
logger.add({
|
||||
level: 'info',
|
||||
source: 'webhook',
|
||||
@@ -1540,7 +1540,7 @@ class WebhookCoordinator {
|
||||
})
|
||||
return
|
||||
}
|
||||
const text = body.replace(/<!--\\s+px:review=1\\s*-->\\s*/i, '').trim()
|
||||
const text = stripReviewMarker(body)
|
||||
if (!text) {
|
||||
logger.add({
|
||||
level: 'warn',
|
||||
@@ -1570,7 +1570,7 @@ class WebhookCoordinator {
|
||||
repo: ctx.repo,
|
||||
index: commentsIndex,
|
||||
})
|
||||
reviewCount = comments.filter(c => /<!--\\s+px:review=1\\s*-->/i.test(c.body ?? '')).length
|
||||
reviewCount = comments.filter(c => hasReviewMarker(c.body ?? '')).length
|
||||
}
|
||||
catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
|
||||
Reference in new issue
Block a user