|
|
@@ -824,24 +824,21 @@ func renderCode(ctx *context.Context) { |
|
|
|
*/ |
|
|
|
baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) |
|
|
|
defer baseGitRepo.Close() |
|
|
|
var compareInfo *git.CompareInfo |
|
|
|
if err != nil { |
|
|
|
log.Error("error open baseRepo:%s", ctx.Repo.Repository.BaseRepo.RepoPath()) |
|
|
|
ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error |
|
|
|
} else { |
|
|
|
if _, error := baseGitRepo.GetBranch(ctx.Repo.BranchName); error == nil { |
|
|
|
//base repo has the same branch, then compare between current repo branch and base repo's branch |
|
|
|
compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.BranchName |
|
|
|
ctx.SetParams("*", compareUrl) |
|
|
|
compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.BranchName) |
|
|
|
ctx.Data["UpstreamSameBranchName"] = true |
|
|
|
} else { |
|
|
|
//else, compare between current repo branch and base repo's default branch |
|
|
|
compareUrl := ctx.Repo.BranchName + "..." + ctx.Repo.Repository.BaseRepo.OwnerName + "/" + ctx.Repo.Repository.BaseRepo.Name + ":" + ctx.Repo.Repository.BaseRepo.DefaultBranch |
|
|
|
ctx.SetParams("*", compareUrl) |
|
|
|
compareInfo, err = baseGitRepo.GetCompareInfo(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName, ctx.Repo.Repository.BaseRepo.DefaultBranch) |
|
|
|
ctx.Data["UpstreamSameBranchName"] = false |
|
|
|
} |
|
|
|
_, _, headGitRepo, compareInfo, _, _ := ParseCompareInfo(ctx) |
|
|
|
defer headGitRepo.Close() |
|
|
|
if compareInfo != nil { |
|
|
|
if err==nil && compareInfo != nil { |
|
|
|
if compareInfo.Commits != nil { |
|
|
|
log.Info("compareInfoCommits数量:%d", compareInfo.Commits.Len()) |
|
|
|
ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() |
|
|
|