|
|
@@ -799,29 +799,32 @@ func renderCode(ctx *context.Context) { |
|
|
|
// 3. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headOwner}/{:headRepoName}:{:headBranch} |
|
|
|
*/ |
|
|
|
baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) |
|
|
|
defer baseGitRepo.Close() |
|
|
|
if err != nil { |
|
|
|
log.Error("error open baseRepo:%s",ctx.Repo.Repository.BaseRepo.RepoPath()) |
|
|
|
} |
|
|
|
defer baseGitRepo.Close() |
|
|
|
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) |
|
|
|
ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error |
|
|
|
}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) |
|
|
|
} |
|
|
|
|
|
|
|
_, _, headGitRepo, compareInfo, _, _ := ParseCompareInfo(ctx) |
|
|
|
defer headGitRepo.Close() |
|
|
|
if compareInfo!= nil { |
|
|
|
if compareInfo.Commits!=nil { |
|
|
|
log.Info("compareInfoCommits数量:%d",compareInfo.Commits.Len()) |
|
|
|
ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() |
|
|
|
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) |
|
|
|
}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) |
|
|
|
} |
|
|
|
_, _, headGitRepo, compareInfo, _, _ := ParseCompareInfo(ctx) |
|
|
|
defer headGitRepo.Close() |
|
|
|
if compareInfo!= nil { |
|
|
|
if compareInfo.Commits!=nil { |
|
|
|
log.Info("compareInfoCommits数量:%d",compareInfo.Commits.Len()) |
|
|
|
ctx.Data["FetchUpstreamCnt"] = compareInfo.Commits.Len() |
|
|
|
}else{ |
|
|
|
log.Info("compareInfo nothing different") |
|
|
|
ctx.Data["FetchUpstreamCnt"] = 0 |
|
|
|
} |
|
|
|
}else{ |
|
|
|
log.Info("compareInfo nothing different") |
|
|
|
ctx.Data["FetchUpstreamCnt"] = 0 |
|
|
|
ctx.Data["FetchUpstreamCnt"] = -1 // minus value indicates error |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|