gitea/services/pull
Lunny Xiao f59d1d3cef
Fix the wrong push commits in the pull request when force push (#36914)
Fix #36905

The changes focus on force-push PR timeline handling and commit range
calculation:
- Reworked pull-request push comment creation to use a new
`gitrepo.GetCommitIDsBetweenReverse` helper, with special handling for
force pushes (merge-base based range, tolerate missing/invalid old
commits, and keep force-push timeline entries).
- Added `Comment.GetPushActionContent` to parse push comment payloads
and used it to delete only non-force-push push comments during force
pushes.
- Removed the old `Repository.CommitsBetweenNotBase` helper from
`modules/git/repo_commit.go` in favor of the new commit ID range helper.
- Added tests for `GetCommitIDsBetweenReverse` (normal range, `notRef`
filtering, fallback branch usage) and expanded pull comment tests to
cover force-push edge cases.

<img width="989" height="563" alt="image"
src="https://github.com/user-attachments/assets/a01e1bc2-fa8a-4028-8a35-d484e601ff3b"
/>

---------

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-04-04 16:27:57 -07:00
..
check.go Pull Request Pusher should be the author of the merge (#36581) 2026-03-02 20:05:58 +00:00
check_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
comment.go Fix the wrong push commits in the pull request when force push (#36914) 2026-04-04 16:27:57 -07:00
comment_test.go Fix the wrong push commits in the pull request when force push (#36914) 2026-04-04 16:27:57 -07:00
commit_status.go Add ability to download subpath archive (#36371) 2026-01-16 09:31:12 +00:00
commit_status_test.go Fix required contexts and commit status matching bug (#34815) 2025-06-22 23:31:46 +00:00
edits.go Fix issue label deletion with Actions tokens (#37013) 2026-03-29 09:21:14 +00:00
lfs.go Refactor git command stdio pipe (#36422) 2026-01-22 06:04:26 +00:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00
merge.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_ff_only.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_merge.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_prepare.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_rebase.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_squash.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_test.go Always use an empty line to separate the commit message and trailer (#34512) 2025-06-02 06:29:16 +00:00
merge_tree.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
merge_tree_test.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
patch.go Fix various trivial problems (#36953) 2026-03-23 18:23:42 +00:00
patch_unmerged.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
protected_branch.go Use git model to detect whether branch exist instead of gitrepo method (#35459) 2025-10-25 10:08:25 -07:00
pull.go Fix the wrong push commits in the pull request when force push (#36914) 2026-04-04 16:27:57 -07:00
pull_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
review.go Enable `nilnil` linter for new code (#36591) 2026-02-16 09:57:18 +00:00
review_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
reviewer.go Fix team permissions (#34827) 2025-06-24 21:24:09 +08:00
reviewer_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
temp_repo.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
update.go Fix issue label deletion with Actions tokens (#37013) 2026-03-29 09:21:14 +00:00
update_rebase.go Use merge tree to detect conflicts when possible (#36400) 2026-01-27 11:57:20 -08:00
update_test.go feat: Add configurable permissions for Actions automatic tokens (#36173) 2026-03-21 15:39:47 -07:00