gitea/modules/gitrepo
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
..
archive.go Refactor git command stdio pipe (#36422) 2026-01-22 06:04:26 +00:00
blame.go Refactor git command stdio pipe (#36422) 2026-01-22 06:04:26 +00:00
blame_sha256_test.go Move blame to gitrepo (#36161) 2025-12-16 16:14:14 -08:00
blame_test.go Move blame to gitrepo (#36161) 2025-12-16 16:14:14 -08:00
branch.go Refactor git command stderr handling (#36402) 2026-01-18 15:10:33 -08:00
cat_file.go Refactor cat-file batch operations and support `--batch-command` approach (#35775) 2026-01-08 13:37:36 -08:00
clone.go Move some functions to gitrepo package to reduce RepoPath reference directly (#36126) 2025-12-12 01:15:40 +01:00
command.go Refactor git command stderr handling (#36402) 2026-01-18 15:10:33 -08:00
commit.go Refactor git command stderr handling (#36402) 2026-01-18 15:10:33 -08:00
commit_file.go Refactor git command stdio pipe (#36422) 2026-01-22 06:04:26 +00:00
commit_file_test.go Move commit related functions to gitrepo package (#35600) 2025-12-05 00:20:23 +00:00
commit_test.go Move some functions to gitrepo package to reduce RepoPath reference directly (#36126) 2025-12-12 01:15:40 +01:00
commitgraph.go Use gitrepo.Repository instead of wikipath (#35398) 2025-10-17 20:00:44 -07:00
compare.go Fix the wrong push commits in the pull request when force push (#36914) 2026-04-04 16:27:57 -07:00
compare_test.go Fix the wrong push commits in the pull request when force push (#36914) 2026-04-04 16:27:57 -07:00
config.go Refactor git command stderr handling (#36402) 2026-01-18 15:10:33 -08:00
diff.go Refactor git command stdio pipe (#36422) 2026-01-22 06:04:26 +00:00
fetch.go Some refactors about GetMergeBase (#36186) 2026-01-17 11:22:09 -08:00
fsck.go Move some functions to gitrepo package (#35543) 2025-10-07 17:06:51 +08:00
gitrepo.go Some refactor for repo path (#36251) 2025-12-29 18:49:54 +00:00
hooks.go Don't create duplicated functions for code repositories and wiki repositories (#33924) 2025-03-19 11:17:19 -07:00
main_test.go Clean up Makefile, tests and legacy code (#36638) 2026-02-19 01:23:32 +00:00
merge.go Refactor git command stderr handling (#36402) 2026-01-18 15:10:33 -08: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
push.go Use gitrepo's clone and push when possible (#36093) 2025-12-10 09:41:01 -08:00
ref.go Move some functions to gitrepo package (#35543) 2025-10-07 17:06:51 +08:00
remote.go Refactor git command stderr handling (#36402) 2026-01-18 15:10:33 -08:00
repo_lock.go Some refactors about GetMergeBase (#36186) 2026-01-17 11:22:09 -08:00
signing.go Remove undocumented support of signing key in the repository git configuration file (#36143) 2025-12-14 17:34:45 +00:00
size.go Move some functions to gitrepo package (#35543) 2025-10-07 17:06:51 +08:00
tag.go Move git references checking to gitrepo packages to reduce expose of repository path (#33891) 2025-03-15 19:48:59 -07:00
url.go
walk_gogit.go
walk_nogogit.go