|
|
@@ -790,6 +790,41 @@ func renderCode(ctx *context.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//如果是fork的仓库 |
|
|
|
if ctx.Repo.Repository.IsFork { |
|
|
|
//获得fetchUpstream对应的分支参数 |
|
|
|
/* |
|
|
|
// 1. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headBranch} |
|
|
|
// 2. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headOwner}:{:headBranch} |
|
|
|
// 3. /{:baseOwner}/{:baseRepoName}/compare/{:baseBranch}...{:headOwner}/{:headRepoName}:{:headBranch} |
|
|
|
*/ |
|
|
|
baseGitRepo, err := git.OpenRepository(ctx.Repo.Repository.BaseRepo.RepoPath()) |
|
|
|
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) |
|
|
|
}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 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Paths"] = paths |
|
|
|
ctx.Data["TreeLink"] = treeLink |
|
|
|
ctx.Data["TreeNames"] = treeNames |
|
|
|