summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-05-31 11:34:05 +0800
committerGitHub <noreply@github.com>2024-05-31 11:34:05 +0800
commitc6176ee59f4a25607dcfbc00757121f705101101 (patch)
treebdbc1c2b38a856b5f8041f41a7991f9656f63a79 /models
parente8c776c79384c1c0a4d707ce5084b27347703848 (diff)
downloadgitea-c6176ee59f4a25607dcfbc00757121f705101101.tar.gz
gitea-c6176ee59f4a25607dcfbc00757121f705101101.zip
Fix branch order (#31174) (#31193)
Backport #31174 by @lunny Fix #31172 The original order or the default order should not be ignored even if we have an is_deleted order. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/git/branch_list.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/models/git/branch_list.go b/models/git/branch_list.go
index 5c887461d5..25e84526d2 100644
--- a/models/git/branch_list.go
+++ b/models/git/branch_list.go
@@ -107,17 +107,13 @@ func (opts FindBranchOptions) ToConds() builder.Cond {
func (opts FindBranchOptions) ToOrders() string {
orderBy := opts.OrderBy
- if opts.IsDeletedBranch.ValueOrDefault(true) { // if deleted branch included, put them at the end
- if orderBy != "" {
- orderBy += ", "
- }
- orderBy += "is_deleted ASC"
- }
if orderBy == "" {
// the commit_time might be the same, so add the "name" to make sure the order is stable
- return "commit_time DESC, name ASC"
+ orderBy = "commit_time DESC, name ASC"
+ }
+ if opts.IsDeletedBranch.ValueOrDefault(true) { // if deleted branch included, put them at the beginning
+ orderBy = "is_deleted ASC, " + orderBy
}
-
return orderBy
}