Skip to content

Conversation

@bimakw
Copy link
Contributor

@bimakw bimakw commented Dec 20, 2025

Summary

This PR adds support for closing keywords (closes, fixes, reopens, etc.) with full URL references in markdown links.

Before:

  • closes #123 ✅ works
  • closes org/repo#123 ✅ works
  • Closes [this issue](https://gitea.io/user/repo/issues/123) ❌ didn't work
  • Fixes [#456](https://gitea.io/org/project/issues/456) ❌ didn't work

After:
All of the above now work correctly.

Problem

When users reference issues using full URLs in markdown links (e.g., Closes [this issue](https://gitea.io/user/repo/issues/123)), the closing keywords were not detected. This was because the URL processing code explicitly stated:

// Note: closing/reopening keywords not supported with URLs

Both methods of writing the reference render the same in the UI, so users expected the closing keywords to behave the same.

Solution

The fix works by:

  1. Passing the original (unstripped) content to findAllIssueReferencesBytes
  2. When processing URL links from markdown, finding the URL position in the original content
  3. For markdown links [text](url), finding the opening bracket [ position
  4. Using that position to detect closing keywords before the link

Testing

Added test cases for:

  • Closes [this issue](url) - single URL with closing keyword
  • This fixes [#456](url) - keyword in middle of text
  • Reopens [PR](url) - reopen keyword with pull request URL
  • Multiple URLs where only one has a closing keyword

All existing tests continue to pass.

Fixes #27549

Previously, closing keywords (closes, fixes, etc.) only worked with
short references like `closes go-gitea#123` or `closes org/repo#123`.

This commit adds support for closing keywords with full URL references
in markdown links, such as:
- `Closes [this issue](https://gitea.io/user/repo/issues/123)`
- `Fixes [go-gitea#456](https://gitea.io/org/project/issues/456)`

The fix works by:
1. Passing the original content to findAllIssueReferencesBytes
2. When processing URL links, finding the URL position in original content
3. For markdown links [text](url), finding the opening bracket position
4. Using that position to detect closing keywords before the link

Fixes go-gitea#27549
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 20, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Dec 20, 2025
@lunny lunny added this to the 1.26.0 milestone Dec 20, 2025
@lunny lunny added the type/enhancement An improvement of existing functionality label Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing keywords do not work with URLs

4 participants