From b9b128e92ff19335a318a6e15fc9ce379905ec8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Mon, 5 Feb 2024 10:51:12 +0100 Subject: [PATCH] put targetversion 'git' to front --- data.go | 11 ++++++++++- issues.go | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/data.go b/data.go index 734669d..944d89b 100644 --- a/data.go +++ b/data.go @@ -267,7 +267,16 @@ func (d *Data) TargetVersions() (tv []string) { for s := range m { tv = append(tv, s) } - sort.Strings(tv) + sort.Slice(tv, + func(i, j int) bool { + if strings.HasPrefix(tv[i], "git") { + return true + } + if strings.HasPrefix(tv[j], "git") { + return false + } + return strings.Compare(tv[i], tv[j]) < 0 + }) return } diff --git a/issues.go b/issues.go index 9d650fc..3c49b4c 100644 --- a/issues.go +++ b/issues.go @@ -125,6 +125,12 @@ type ByTarget []*Issue func (b ByTarget) Len() int { return len(b) } func (b ByTarget) Less(i, j int) bool { + if strings.HasPrefix(b[i].TargetVersion.Name, "git") { + return true + } + if strings.HasPrefix(b[j].TargetVersion.Name, "git") { + return false + } return strings.Compare(b[i].TargetVersion.Name, b[j].TargetVersion.Name) < 0 } func (b ByTarget) Swap(i, j int) { b[i], b[j] = b[j], b[i] } @@ -268,8 +274,16 @@ var lessFuncs = map[string]lessFunc{ "Category": func(i1, i2 *Issue) bool { return strings.Compare(i1.Category.Name, i2.Category.Name) < 0 }, "Assignment": func(i1, i2 *Issue) bool { return strings.Compare(i1.Handler.Name, i2.Handler.Name) < 0 }, "Handler": func(i1, i2 *Issue) bool { return strings.Compare(i1.Handler.Name, i2.Handler.Name) < 0 }, - "Target": func(i1, i2 *Issue) bool { return strings.Compare(i1.TargetVersion.Name, i2.TargetVersion.Name) < 0 }, - "Id": func(i1, i2 *Issue) bool { return i1.Id < i2.Id }, + "Target": func(i1, i2 *Issue) bool { + if strings.HasPrefix(i1.TargetVersion.Name, "git") { + return true + } + if strings.HasPrefix(i2.TargetVersion.Name, "git") { + return false + } + return strings.Compare(i1.TargetVersion.Name, i2.TargetVersion.Name) < 0 + }, + "Id": func(i1, i2 *Issue) bool { return i1.Id < i2.Id }, "Severity": func(i1, i2 *Issue) bool { s1, ok := severityOrder[i1.Severity.Name] if !ok {