Skip to content

Commit 2aa6a78

Browse files
authored
Make FindBranches have stable result (#25631)
See the comment
1 parent 7735da1 commit 2aa6a78

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

models/git/branch_list.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ func (branches BranchList) LoadPusher(ctx context.Context) error {
6464
return nil
6565
}
6666

67-
const (
68-
BranchOrderByNameAsc = "name ASC"
69-
BranchOrderByCommitTimeDesc = "commit_time DESC"
70-
)
71-
7267
type FindBranchOptions struct {
7368
db.ListOptions
7469
RepoID int64
@@ -102,7 +97,8 @@ func orderByBranches(sess *xorm.Session, opts FindBranchOptions) *xorm.Session {
10297
}
10398

10499
if opts.OrderBy == "" {
105-
opts.OrderBy = BranchOrderByCommitTimeDesc
100+
// the commit_time might be the same, so add the "name" to make sure the order is stable
101+
opts.OrderBy = "commit_time DESC, name ASC"
106102
}
107103
return sess.OrderBy(opts.OrderBy)
108104
}

0 commit comments

Comments
 (0)