Clone
2
lessons/patterns/use-fixes-n-keyword-for-automatic-issue-closing-in-prs
Leo Miranda edited this page 2026-01-29 01:49:24 +00:00

Context

  • 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

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.

Solution

For this repository's workflow (feature → development → main):

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. 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

Tags: gitea, pr, issue-linking, workflow, auto-close, default-branch