Update "lessons%2Fpatterns%2Fuse-fixes-n-keyword-for-automatic-issue-closing-in-prs.-"
@@ -1,40 +1,56 @@
|
|||||||
## Context
|
## Context
|
||||||
|
|
||||||
- Created PR #292 with "Partial fix for #290" in the body
|
- Created PR #291 with "Fixes #287" and PR #292 with "Partial fix for #290"
|
||||||
- Expected Gitea to link the PR to the issue
|
- Both PRs merged to `development` branch
|
||||||
- Issue remained open after PR was merged
|
- Neither issue was auto-closed by Gitea
|
||||||
|
|
||||||
## Problem
|
## Problem
|
||||||
|
|
||||||
Gitea only auto-closes issues when specific keywords are used:
|
**Two root causes identified:**
|
||||||
|
|
||||||
|
### 1. Auto-close only works on DEFAULT branch merges
|
||||||
|
|
||||||
|
Gitea only auto-closes issues when PRs are merged to the **default branch** (usually `main`).
|
||||||
|
|
||||||
|
- Repository default branch: `main`
|
||||||
|
- PRs were merged to: `development`
|
||||||
|
- Result: Even with correct "Fixes #287" keyword, no auto-close
|
||||||
|
|
||||||
|
### 2. Wrong keyword format
|
||||||
|
|
||||||
|
Gitea only recognizes specific keywords:
|
||||||
- `Fixes #N`
|
- `Fixes #N`
|
||||||
- `Closes #N`
|
- `Closes #N`
|
||||||
- `Resolves #N`
|
- `Resolves #N`
|
||||||
|
|
||||||
Using "Partial fix for #290" does NOT trigger auto-close because "Partial" is not a recognized keyword.
|
Using "Partial fix for #290" does NOT trigger auto-close.
|
||||||
|
|
||||||
## Solution
|
## Solution
|
||||||
|
|
||||||
For PRs that fully address an issue:
|
**For this repository's workflow (feature → development → main):**
|
||||||
- Use `Fixes #N` in the PR body or commit message
|
|
||||||
|
|
||||||
For PRs that partially address an issue:
|
Option A: Manually close issues after merging to development
|
||||||
- Use `Fixes #N` if you want auto-close anyway
|
Option B: Include "Fixes #N" in the development→main PR body
|
||||||
- OR manually close the issue after merge
|
Option C: Change repository default branch to development (not recommended)
|
||||||
- Consider creating separate issues for remaining work
|
|
||||||
|
**For keyword format:**
|
||||||
|
- Always use `Fixes #N` format (not "Partial fix", "Related to", etc.)
|
||||||
|
- If partial fix, either:
|
||||||
|
- Use `Fixes #N` anyway and create follow-up issues for remaining work
|
||||||
|
- Manually close the issue after merge
|
||||||
|
|
||||||
## Prevention
|
## Prevention
|
||||||
|
|
||||||
When creating PRs:
|
When creating PRs:
|
||||||
1. Always use `Fixes #N` format for issue linking
|
1. Use `Fixes #N` format for issue linking
|
||||||
2. If partial fix, decide upfront: auto-close or keep open
|
2. Remember: auto-close only triggers on merges to DEFAULT branch
|
||||||
3. Add remaining work items to issue comment before closing
|
3. For development branch merges, plan to manually close issues
|
||||||
4. Or create follow-up issues for remaining criteria
|
4. Or include the fix reference in your development→main PR
|
||||||
|
|
||||||
## Related
|
## Related
|
||||||
|
|
||||||
- Issue: #290
|
- Issue: #287, #290
|
||||||
- PR: #292
|
- PR: #291, #292
|
||||||
|
|
||||||
---
|
---
|
||||||
**Tags:** gitea, pr, issue-linking, workflow, auto-close
|
**Tags:** gitea, pr, issue-linking, workflow, auto-close, default-branch
|
||||||
Reference in New Issue
Block a user