diff --git a/routers/web/repo/view_home.go b/routers/web/repo/view_home.go index 1bd67e0ba0a33..48c9131ecfca3 100644 --- a/routers/web/repo/view_home.go +++ b/routers/web/repo/view_home.go @@ -227,7 +227,7 @@ func prepareRecentlyPushedNewBranches(ctx *context.Context) { continue } // Base is the pushed branch (for fork branch or local pushed branch perspective) - if divergingInfo.BaseIsNewer || divergingInfo.CommitsBehind > 0 { + if divergingInfo.BaseHasNewCommits || divergingInfo.CommitsBehind > 0 { finalBranches = append(finalBranches, branch) } } diff --git a/services/repository/branch.go b/services/repository/branch.go index 280efb8ee3983..ef956093780b9 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -645,9 +645,9 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR } type BranchDivergingInfo struct { - BaseIsNewer bool - CommitsBehind int - CommitsAhead int + BaseHasNewCommits bool + CommitsBehind int + CommitsAhead int } // getBranchDivergingInfo returns the information about the divergence of a patch branch to the base branch. @@ -672,8 +672,8 @@ func GetBranchDivergingInfo(ctx reqctx.RequestContext, baseRepo, headRepo *repo_ // so at the moment, we first check the update time, then check whether the fork branch has base's head diff, err := git.GetDivergingCommits(ctx, baseRepo.RepoPath(), baseGitBranch.CommitID, headGitBranch.CommitID) if err != nil { - info.BaseIsNewer = baseGitBranch.UpdatedUnix > headGitBranch.UpdatedUnix - if headRepo.IsFork && info.BaseIsNewer { + info.BaseHasNewCommits = baseGitBranch.UpdatedUnix > headGitBranch.UpdatedUnix + if headRepo.IsFork && info.BaseHasNewCommits { return info, nil } // if the base's update time is before the fork, check whether the base's head is in the fork @@ -694,7 +694,7 @@ func GetBranchDivergingInfo(ctx reqctx.RequestContext, baseRepo, headRepo *repo_ return nil, err } hasPreviousCommit, _ := headCommit.HasPreviousCommit(baseCommitID) - info.BaseIsNewer = !hasPreviousCommit + info.BaseHasNewCommits = !hasPreviousCommit return info, nil } diff --git a/templates/repo/code/upstream_diverging_info.tmpl b/templates/repo/code/upstream_diverging_info.tmpl index e361cf263b8d6..bdcd99a7f7e22 100644 --- a/templates/repo/code/upstream_diverging_info.tmpl +++ b/templates/repo/code/upstream_diverging_info.tmpl @@ -1,4 +1,4 @@ -{{if and .UpstreamDivergingInfo (or .UpstreamDivergingInfo.BaseIsNewer .UpstreamDivergingInfo.CommitsBehind)}} +{{if and .UpstreamDivergingInfo (or .UpstreamDivergingInfo.BaseHasNewCommits .UpstreamDivergingInfo.CommitsBehind)}}
{{$upstreamLink := printf "%s/src/branch/%s" .Repository.BaseRepo.Link (.Repository.BaseRepo.DefaultBranch|PathEscapeSegments)}}