Skip to content

Commit 36959c7

Browse files
committed
fix(webhook):with Issue.IsPullRequest()
1 parent 9a5c92c commit 36959c7

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

internal/webhook/handler.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ func (h *Handler) handleIssueComment(ctx context.Context, w http.ResponseWriter,
150150
log.Infof("Processing issue comment: issue=#%d, title=%s, comment_length=%d",
151151
issueNumber, issueTitle, len(comment))
152152

153-
// 检查是否是 PR 评论(Issue 的 PullRequest 字段不为空)
154-
if event.Issue.PullRequestLinks != nil {
153+
if event.Issue.IsPullRequest() {
155154
log.Infof("Detected PR comment for PR #%d", issueNumber)
156155

157156
// 这是 PR 评论,处理 /continue 和 /fix 命令
@@ -200,16 +199,8 @@ func (h *Handler) handleIssueComment(ctx context.Context, w http.ResponseWriter,
200199
}
201200
}
202201

203-
// Handle /code command for Issues only (not for PRs)
204-
if strings.HasPrefix(comment, "/code") {
205-
// Check if this is a PR comment, ignore if it is
206-
if event.Issue.PullRequestLinks != nil {
207-
log.Infof("Ignoring /code command in PR #%d (use /continue or /fix instead)", issueNumber)
208-
w.WriteHeader(http.StatusOK)
209-
w.Write([]byte("/code command is not supported in PRs, use /continue or /fix instead"))
210-
return
211-
}
212-
202+
// Handle /code command for issues only (not for PRs)
203+
if strings.HasPrefix(comment, "/code") && !event.Issue.IsPullRequest() {
213204
log.Infof("Received /code command for Issue: %s, title: %s",
214205
event.Issue.GetHTMLURL(), issueTitle)
215206

0 commit comments

Comments
 (0)