chore: repo compare link (#39088)

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
wxiaoguang
2026-08-25 17:52:21 +00:00
committed by GitHub
co-authored by silverwind
parent 38747d48fe
commit 7668e7c00d
4 changed files with 31 additions and 18 deletions
+9 -8
View File
@@ -1297,18 +1297,19 @@ func stopTimerIfAvailable(ctx *context.Context, user *user_model.User, issue *is
}
func PullsNewRedirect(ctx *context.Context) {
branch := ctx.PathParam("*")
redirectRepo := ctx.Repo.Repository
repo := ctx.Repo.Repository
if repo.IsFork {
if err := repo.GetBaseRepo(ctx); err != nil {
branchName := ctx.PathParam("*")
baseRepo, headRepo := ctx.Repo.Repository, ctx.Repo.Repository
if headRepo.IsFork {
if err := headRepo.GetBaseRepo(ctx); err != nil {
ctx.ServerError("GetBaseRepo", err)
return
}
redirectRepo = repo.BaseRepo
branch = context.CompareHeadRef(repo, branch)
baseRepo = headRepo.BaseRepo
}
ctx.Redirect(fmt.Sprintf("%s/compare/%s...%s?expand=1", redirectRepo.Link(), util.PathEscapeSegments(redirectRepo.DefaultBranch), util.PathEscapeSegments(branch)))
ctx.Redirect(fmt.Sprintf("%s/compare/%s...%s?expand=1", baseRepo.Link(),
util.PathEscapeSegments(baseRepo.DefaultBranch),
util.PathEscapeSegments(context.CompareHeadRef(baseRepo, headRepo, branchName)),
))
}
// CompareAndPullRequestPost response for creating pull request