chore: repo compare link (#39088) (#39119)

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Giteabot
2026-08-25 18:52:54 +00:00
committed by GitHub
co-authored by wxiaoguang silverwind
parent b70f7aeda1
commit d2572c7342
4 changed files with 31 additions and 18 deletions
+9 -8
View File
@@ -1307,18 +1307,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