summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
}