1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-21 12:44:49 -05:00

Make FindBranches have stable result (#25631)

See the comment
This commit is contained in:
wxiaoguang 2023-07-03 12:11:32 +08:00 committed by GitHub
parent 7735da1c66
commit 2aa6a785cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,11 +64,6 @@ func (branches BranchList) LoadPusher(ctx context.Context) error {
return nil
}
const (
BranchOrderByNameAsc = "name ASC"
BranchOrderByCommitTimeDesc = "commit_time DESC"
)
type FindBranchOptions struct {
db.ListOptions
RepoID int64
@ -102,7 +97,8 @@ func orderByBranches(sess *xorm.Session, opts FindBranchOptions) *xorm.Session {
}
if opts.OrderBy == "" {
opts.OrderBy = BranchOrderByCommitTimeDesc
// the commit_time might be the same, so add the "name" to make sure the order is stable
opts.OrderBy = "commit_time DESC, name ASC"
}
return sess.OrderBy(opts.OrderBy)
}