Quellcode durchsuchen

ci: prevent duplicate PR check from flagging current PR as duplicate (#6924)

Co-authored-by: Aiden Cline <[email protected]>
Ravi Kumar vor 1 Monat
Ursprung
Commit
c6a241e331

+ 2 - 0
.github/workflows/duplicate-prs.yml

@@ -44,6 +44,8 @@ jobs:
           {
           {
             echo "Check for duplicate PRs related to this new PR:"
             echo "Check for duplicate PRs related to this new PR:"
             echo ""
             echo ""
+            echo "CURRENT_PR_NUMBER: $PR_NUMBER"
+            echo ""
             echo "Title: $(gh pr view "$PR_NUMBER" --json title --jq .title)"
             echo "Title: $(gh pr view "$PR_NUMBER" --json title --jq .title)"
             echo ""
             echo ""
             echo "Description:"
             echo "Description:"

+ 2 - 0
.opencode/agent/duplicate-pr.md

@@ -12,6 +12,8 @@ You are a duplicate PR detection agent. When a PR is opened, your job is to sear
 
 
 Use the github-pr-search tool to search for PRs that might be addressing the same issue or feature.
 Use the github-pr-search tool to search for PRs that might be addressing the same issue or feature.
 
 
+IMPORTANT: The input will contain a line `CURRENT_PR_NUMBER: NNNN`. This is the current PR number, you should not mark that the current PR as a duplicate of itself.
+
 Search using keywords from the PR title and description. Try multiple searches with different relevant terms.
 Search using keywords from the PR title and description. Try multiple searches with different relevant terms.
 
 
 If you find potential duplicates:
 If you find potential duplicates:

+ 5 - 0
.opencode/tool/github-pr-search.ts

@@ -45,6 +45,11 @@ export default tool({
     }
     }
 
 
     const prs = result.items as PR[]
     const prs = result.items as PR[]
+
+    if (prs.length === 0) {
+      return `No other PRs found matching "${args.query}"`
+    }
+
     const formatted = prs.map((pr) => `${pr.title}\n${pr.html_url}`).join("\n\n")
     const formatted = prs.map((pr) => `${pr.title}\n${pr.html_url}`).join("\n\n")
 
 
     return `Found ${result.total_count} PRs (showing ${prs.length}):\n\n${formatted}`
     return `Found ${result.total_count} PRs (showing ${prs.length}):\n\n${formatted}`