Skip to content

Commit

Permalink
revert the name of divergence info
Browse files Browse the repository at this point in the history
  • Loading branch information
changchaishi committed Jan 15, 2025
1 parent e4e7766 commit f46b1a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion routers/web/repo/view_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
12 changes: 6 additions & 6 deletions services/repository/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion templates/repo/code/upstream_diverging_info.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{if and .UpstreamDivergingInfo (or .UpstreamDivergingInfo.BaseIsNewer .UpstreamDivergingInfo.CommitsBehind)}}
{{if and .UpstreamDivergingInfo (or .UpstreamDivergingInfo.BaseHasNewCommits .UpstreamDivergingInfo.CommitsBehind)}}
<div class="ui message flex-text-block">
<div class="tw-flex-1">
{{$upstreamLink := printf "%s/src/branch/%s" .Repository.BaseRepo.Link (.Repository.BaseRepo.DefaultBranch|PathEscapeSegments)}}
Expand Down

0 comments on commit f46b1a6

Please sign in to comment.