aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-07-03 12:11:32 +0800
committerGitHub <noreply@github.com>2023-07-03 04:11:32 +0000
commit2aa6a785cf9b066fb0a297b1bdc3fb431fa25667 (patch)
treef5ff3e374e7195e6658db50509c516896965eb3b /models
parent7735da1c66c5a1511a2eac04b2a7f5c60b214c83 (diff)
downloadgitea-2aa6a785cf9b066fb0a297b1bdc3fb431fa25667.tar.gz
gitea-2aa6a785cf9b066fb0a297b1bdc3fb431fa25667.zip
Make FindBranches have stable result (#25631)
See the comment
Diffstat (limited to 'models')
-rw-r--r--models/git/branch_list.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/models/git/branch_list.go b/models/git/branch_list.go
index 836d4ffc41..131a149782 100644
--- a/models/git/branch_list.go
+++ b/models/git/branch_list.go
@@ -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)
}