1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor all compare routers

This commit is contained in:
Lunny Xiao
2024-12-11 00:23:12 -08:00
parent f19b4b7967
commit 4ee5334c10
8 changed files with 141 additions and 204 deletions

View File

@@ -105,25 +105,6 @@ func CompareDiff(ctx *context.APIContext) {
ctx.Repo.PullRequest.SameRepo = ci.IsSameRepo()
log.Trace("Repo path: %q, base branch: %q, head branch: %q", ctx.Repo.GitRepo.Path, ci.BaseOriRef, ci.HeadOriRef)
// Check if current user has fork of repository or in the same repository.
/*headRepo := repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, ctx.Repo.Repository.ID)
if headRepo == nil && !ci.IsSameRepo() {
err := ctx.Repo.Repository.GetBaseRepo(ctx)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBaseRepo", err)
return nil, nil, nil, "", ""
}
// Check if baseRepo's base repository is the same as headUser's repository.
if baseRepo.BaseRepo == nil || baseRepo.BaseRepo.OwnerID != headUser.ID {
log.Trace("parseCompareInfo[%d]: does not have fork or in same repository", baseRepo.ID)
ctx.NotFound("GetBaseRepo")
return nil, nil, nil, "", ""
}
// Assign headRepo so it can be used below.
headRepo = baseRepo.BaseRepo
}*/
ci.CompareInfo, err = ci.HeadGitRepo.GetCompareInfo(repo_model.RepoPath(baseRepo.Owner.Name, baseRepo.Name), ci.BaseOriRef, ci.HeadOriRef, false, false)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetCompareInfo", err)