Skip to content

Commit c6176ee

Browse files
GiteaBotlunny
andauthored
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 <[email protected]>
1 parent e8c776c commit c6176ee

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

models/git/branch_list.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,13 @@ func (opts FindBranchOptions) ToConds() builder.Cond {
107107

108108
func (opts FindBranchOptions) ToOrders() string {
109109
orderBy := opts.OrderBy
110-
if opts.IsDeletedBranch.ValueOrDefault(true) { // if deleted branch included, put them at the end
111-
if orderBy != "" {
112-
orderBy += ", "
113-
}
114-
orderBy += "is_deleted ASC"
115-
}
116110
if orderBy == "" {
117111
// the commit_time might be the same, so add the "name" to make sure the order is stable
118-
return "commit_time DESC, name ASC"
112+
orderBy = "commit_time DESC, name ASC"
113+
}
114+
if opts.IsDeletedBranch.ValueOrDefault(true) { // if deleted branch included, put them at the beginning
115+
orderBy = "is_deleted ASC, " + orderBy
119116
}
120-
121117
return orderBy
122118
}
123119

0 commit comments

Comments
 (0)