Compare commits
1 Commits
fix/1459
...
burn/1500-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b9672d82b |
89
docs/duplicate-pr-prevention.md
Normal file
89
docs/duplicate-pr-prevention.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Duplicate PR Prevention System
|
||||
|
||||
## Overview
|
||||
|
||||
The Nexus uses a multi-layer system to prevent duplicate PRs for the same issue.
|
||||
|
||||
## Components
|
||||
|
||||
### 1. Pre-flight Check (CI)
|
||||
|
||||
The `.github/workflows/pr-duplicate-check.yml` workflow runs on every PR creation and checks if a PR already exists for the same issue.
|
||||
|
||||
**How it works:**
|
||||
1. Extracts issue numbers from PR title and body
|
||||
2. Queries Gitea API for existing PRs referencing those issues
|
||||
3. Fails the check if duplicates are found
|
||||
4. Provides links to existing PRs for review
|
||||
|
||||
### 2. Cleanup Script
|
||||
|
||||
The `scripts/cleanup-duplicate-prs.sh` script helps clean up existing duplicates:
|
||||
- Lists all PRs for a given issue
|
||||
- Identifies duplicates
|
||||
- Provides commands to close duplicates
|
||||
|
||||
### 3. Milestone Checker
|
||||
|
||||
The `bin/check_duplicate_milestones.py` script prevents duplicate milestones:
|
||||
- Scans all milestones in the repo
|
||||
- Identifies duplicates by title
|
||||
- Reports for manual cleanup
|
||||
|
||||
## Usage
|
||||
|
||||
### Check for Duplicates Before Creating PR
|
||||
|
||||
```bash
|
||||
# Check if issue already has PRs
|
||||
curl -s -H "Authorization: token $GITEA_TOKEN" \
|
||||
"https://forge.alexanderwhitestone.com/api/v1/repos/Timmy_Foundation/the-nexus/pulls?state=open" \
|
||||
| jq '.[] | select(.body | contains("#ISSUE_NUMBER"))'
|
||||
```
|
||||
|
||||
### Clean Up Existing Duplicates
|
||||
|
||||
```bash
|
||||
# List PRs for issue
|
||||
./scripts/cleanup-duplicate-prs.sh --issue 1128
|
||||
|
||||
# Close duplicates (keep newest)
|
||||
./scripts/cleanup-duplicate-prs.sh --issue 1128 --close-duplicates
|
||||
```
|
||||
|
||||
## Example: Issue #1500
|
||||
|
||||
Issue #1500 documented that the pre-flight check successfully prevented a duplicate PR for #1474.
|
||||
|
||||
**What happened:**
|
||||
1. Dispatch attempted to work on #1474
|
||||
2. Pre-flight check found 2 existing PRs (#1495, #1493)
|
||||
3. System prevented creating a 3rd duplicate
|
||||
4. Issue #1500 was filed as an observation
|
||||
|
||||
**Result:** The system worked as intended.
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Always check before creating PRs** — use the pre-flight check
|
||||
2. **Close duplicates promptly** — don't let them accumulate
|
||||
3. **Reference issues in PRs** — makes duplicate detection possible
|
||||
4. **Use descriptive branch names** — helps identify purpose
|
||||
5. **Review existing PRs first** — don't assume you're the first
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Duplicate PR detected" error
|
||||
|
||||
This means a PR already exists for the issue. Options:
|
||||
1. Review the existing PR and contribute to it
|
||||
2. Close your PR if it's truly a duplicate
|
||||
3. Update your PR to address a different aspect
|
||||
|
||||
### Pre-flight check not running
|
||||
|
||||
Check that `.github/workflows/pr-duplicate-check.yml` exists and is enabled.
|
||||
|
||||
### False positives
|
||||
|
||||
The check looks for issue numbers in PR body. If you're referencing an issue without intending to fix it, use "Refs #" instead of "Fixes #".
|
||||
Reference in New Issue
Block a user