diff --git a/pkg/app/handler/packages/overview.templ b/pkg/app/handler/packages/overview.templ
index 72019aa..291fee8 100644
--- a/pkg/app/handler/packages/overview.templ
+++ b/pkg/app/handler/packages/overview.templ
@@ -140,7 +140,7 @@ templ useFlagsGroup(title string, useflags []*models.Useflag) {
= 10), templ.KV("kk-useflag-container-few", len(useflags) < 10) }>
for _, use := range useflags {
-
- { use.Name }
+ { use.Name }
}
diff --git a/pkg/app/handler/packages/utils.go b/pkg/app/handler/packages/utils.go
index 7b319e0..99dbf53 100644
--- a/pkg/app/handler/packages/utils.go
+++ b/pkg/app/handler/packages/utils.go
@@ -6,6 +6,7 @@ package packages
import (
"log/slog"
"net/http"
+ "slices"
"soko/pkg/database"
"soko/pkg/models"
"sort"
@@ -140,7 +141,7 @@ func getParameterValue(parameterName string, r *http.Request) string {
// getPackageUseflags retrieves all local USE flags, global USE
// flags and use expands for a given package
func getPackageUseflags(gpackage *models.Package) (localUseflags []*models.Useflag, filteredGlobalUseflags []*models.Useflag, useExpands map[string][]*models.Useflag) {
- rawUseFlags := gpackage.AllUseflags()
+ rawUseFlags, defaultOn := gpackage.AllUseflags()
if len(rawUseFlags) == 0 {
return
}
@@ -163,6 +164,7 @@ func getPackageUseflags(gpackage *models.Package) (localUseflags []*models.Usefl
var allGlobalUseflags []*models.Useflag
useExpands = make(map[string][]*models.Useflag)
for _, useflag := range tmp_useflags {
+ isDefaultOn := slices.Contains(defaultOn, useflag.Name)
if useflag.Scope == "global" {
allGlobalUseflags = append(allGlobalUseflags, useflag)
} else if useflag.Scope == "local" {
@@ -173,6 +175,9 @@ func getPackageUseflags(gpackage *models.Package) (localUseflags []*models.Usefl
useflag.Name = strings.TrimPrefix(useflag.Name, useflag.UseExpand+"_")
useExpands[useflag.UseExpand] = append(useExpands[useflag.UseExpand], useflag)
}
+ if isDefaultOn {
+ useflag.Name = "+" + useflag.Name
+ }
}
// Only add global useflags that are not present in the local useflags
diff --git a/pkg/models/package.go b/pkg/models/package.go
index e0a1ce3..16f1b61 100644
--- a/pkg/models/package.go
+++ b/pkg/models/package.go
@@ -145,17 +145,27 @@ func (p Package) AllBugs() []*Bug {
return allBugsList
}
-func (p *Package) AllUseflags() []string {
- useflags := make(map[string]struct{})
+func (p *Package) AllUseflags() (useflags []string, defaultOn []string) {
+ useflagsSet := make(map[string]struct{})
+ defaultOnSet := make(map[string]struct{})
for _, version := range p.Versions {
for _, useflag := range version.Useflags {
- useflags[strings.TrimPrefix(useflag, "+")] = struct{}{}
+ if useflag[0] == '+' {
+ defaultOnSet[useflag[1:]] = struct{}{}
+ useflagsSet[useflag[1:]] = struct{}{}
+ } else {
+ useflagsSet[useflag] = struct{}{}
+ }
}
}
- useflagsList := make([]string, 0, len(useflags))
- for useflag := range useflags {
- useflagsList = append(useflagsList, useflag)
+ useflags = make([]string, 0, len(useflagsSet))
+ for useflag := range useflagsSet {
+ useflags = append(useflags, useflag)
+ }
+ defaultOn = make([]string, 0, len(defaultOnSet))
+ for useflag := range defaultOnSet {
+ defaultOn = append(defaultOn, useflag)
}
- return useflagsList
+ return
}