jojo/models/unittest
Mathieu Fenniak 40aa3a5c7d fix: mark code comments as Outdated based upon line-of-code existence in current PR commit (#12054)
Currently when a commit is pushed to a branch, code comments are marked as Outdated if a `git blame` on the current commit's code returns the same commit as the `git blame` did when the comment was originally created.  This implementation doesn't make sense:
- It doesn't handle the case correctly where the same line of code exists unaltered in the new commit, but it has been relocated (eg. new lines entered or removed above the location).
- It falsely keeps the commit valid if the line of code that the comment was made upon has been removed, if, coincidentally, the line of code that now exists at the commit came from the same source commit.  For example, if the line of code that the comment was on was deleted, but the next line of code came from the same commit, the comment will be kept as valid.

This PR uses the logic introduced in #12015, using a `git blame --reverse` -- the commit & line that was identified as having the comment on it is reversed, and if it still exists in the new head, then the comment is considered valid.  Otherwise it is marked as outdated.

Automated tests are added primarily by revising the automated tests in #12015 -- a comment in an existing test case was marked as outdated, even though it shouldn't have been.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. All work and communication must conform to Forgejo's [AI Agreement](https://codeberg.org/forgejo/governance/src/branch/main/AIAgreement.md). There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests for Go changes

- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
  - [x] `make pr-go` before pushing

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

<!--start release-notes-assistant-->

## Release notes
<!--URL:https://codeberg.org/forgejo/forgejo-->
- Bug fixes
  - [PR](https://codeberg.org/forgejo/forgejo/pulls/12054): <!--number 12054 --><!--line 0 --><!--description bWFyayBjb2RlIGNvbW1lbnRzIGFzIE91dGRhdGVkIGJhc2VkIHVwb24gbGluZS1vZi1jb2RlIGV4aXN0ZW5jZSBpbiBjdXJyZW50IFBSIGNvbW1pdA==-->mark code comments as Outdated based upon line-of-code existence in current PR commit<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12054
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2026-04-11 23:10:34 +02:00
..
testdata fix NewMockWebServer(): Headers never reached the http client (#11007) 2026-01-24 04:51:18 +01:00
consistency.go fix: reduce deadlocks merging PRs by using caching for repo issue count stats (#9922) 2025-10-31 23:50:05 +01:00
fault_injector.go chore: add SQL fault injector testing (#9314) 2025-09-18 00:39:06 +02:00
fault_injector_test.go chore: add SQL fault injector testing (#9314) 2025-09-18 00:39:06 +02:00
fixture_loader.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
fixtures.go feat: add foreign keys to stopwatch & tracked_time tables (#9373) 2025-10-01 00:31:38 +02:00
fscopy.go chore: simplify CopyDir 2024-11-10 17:21:57 +01:00
mock_http.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
mock_http_test.go fix NewMockWebServer(): Headers never reached the http client (#11007) 2026-01-24 04:51:18 +01:00
reflection.go chore: add modernizer linter (#11936) 2026-04-02 03:29:37 +02:00
testdb.go fix: reduce deadlocks merging PRs w/ async label stat recalcs (#9868) 2025-10-31 02:12:36 +01:00
unit_tests.go fix: mark code comments as Outdated based upon line-of-code existence in current PR commit (#12054) 2026-04-11 23:10:34 +02:00