diff --git a/lessons%2Fpatterns%2Fuse-fixes-n-keyword-for-automatic-issue-closing-in-prs.-.md b/lessons%2Fpatterns%2Fuse-fixes-n-keyword-for-automatic-issue-closing-in-prs.-.md index 6652984..3c014b7 100644 --- a/lessons%2Fpatterns%2Fuse-fixes-n-keyword-for-automatic-issue-closing-in-prs.-.md +++ b/lessons%2Fpatterns%2Fuse-fixes-n-keyword-for-automatic-issue-closing-in-prs.-.md @@ -1,40 +1,56 @@ ## Context -- Created PR #292 with "Partial fix for #290" in the body -- Expected Gitea to link the PR to the issue -- Issue remained open after PR was merged +- Created PR #291 with "Fixes #287" and PR #292 with "Partial fix for #290" +- Both PRs merged to `development` branch +- Neither issue was auto-closed by Gitea ## 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` - `Closes #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 -For PRs that fully address an issue: -- Use `Fixes #N` in the PR body or commit message +**For this repository's workflow (feature → development → main):** -For PRs that partially address an issue: -- Use `Fixes #N` if you want auto-close anyway -- OR manually close the issue after merge -- Consider creating separate issues for remaining work +Option A: Manually close issues after merging to development +Option B: Include "Fixes #N" in the development→main PR body +Option C: Change repository default branch to development (not recommended) + +**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 When creating PRs: -1. Always use `Fixes #N` format for issue linking -2. If partial fix, decide upfront: auto-close or keep open -3. Add remaining work items to issue comment before closing -4. Or create follow-up issues for remaining criteria +1. Use `Fixes #N` format for issue linking +2. Remember: auto-close only triggers on merges to DEFAULT branch +3. For development branch merges, plan to manually close issues +4. Or include the fix reference in your development→main PR ## Related -- Issue: #290 -- PR: #292 +- Issue: #287, #290 +- PR: #291, #292 --- -**Tags:** gitea, pr, issue-linking, workflow, auto-close \ No newline at end of file +**Tags:** gitea, pr, issue-linking, workflow, auto-close, default-branch \ No newline at end of file