fix(pull): fetch PR head refs instead of pushing them (#39603) (#39607)

Backport https://github.com/go-gitea/gitea/pull/39603 by @silverwind

Uses `FetchRemoteCommit`, as v28 has no `FetchRemoteTempCommit`, so no
`--no-write-fetch-head` is involved.
This commit is contained in:
silverwind authored and GitHub committed 2026-10-05 20:31:46 +02:00
1 parent 08c123299a
commit e66e773a6f
2 files changed
+13 -33

No files matched your search

+2 -15
View File
@@ -17,7 +17,6 @@ import (
"gitea.dev/modules/git"
"gitea.dev/modules/log"
"gitea.dev/modules/markup/markdown"
repo_module "gitea.dev/modules/repository"
"gitea.dev/modules/setting"
api "gitea.dev/modules/structs"
"gitea.dev/modules/util"
@@ -137,21 +136,9 @@ func NewComment(ctx *context.Context) {
return
}
err = pull.LoadIssue(ctx)
if err != nil {
ctx.ServerError("load the issue of pull request error", err)
return
}
if prHeadCommitID != headBranchCommitID {
// force push to base repo
err := git.PushManaged(ctx, pull.HeadRepo, pull.BaseRepo, git.PushOptions{
Branch: pull.HeadBranch + ":" + prHeadRef,
Force: true,
Env: repo_module.InternalPushingEnvironment(pull.Issue.Poster, pull.BaseRepo),
})
if err != nil {
ctx.ServerError("force push error", err)
if err := pull_service.PushToBaseRepo(ctx, pull); err != nil {
ctx.ServerError("PushToBaseRepo", err)
return
}
}