mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-29 11:20:42 +00:00
Fix branch order (#31174)
Fix #31172 The original order or the default order should not be ignored even if we have an is_deleted order. (cherry picked from commit 1137a0357eb1e35a046e86a7277594154d0f6c85)
This commit is contained in:
parent
ee2247d77c
commit
18eef3b23a
1 changed files with 4 additions and 8 deletions
|
@ -88,17 +88,13 @@ func (opts FindBranchOptions) ToConds() builder.Cond {
|
||||||
|
|
||||||
func (opts FindBranchOptions) ToOrders() string {
|
func (opts FindBranchOptions) ToOrders() string {
|
||||||
orderBy := opts.OrderBy
|
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 == "" {
|
if orderBy == "" {
|
||||||
// the commit_time might be the same, so add the "name" to make sure the order is stable
|
// 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
|
return orderBy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue