From 75fd8b5b3e1bdc2ae4dda96cc8ee81b1d56870f7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 5 Dec 2025 20:38:42 -0800 Subject: [PATCH] Fix lint --- .../render-plugins/example-wasm/wasm/main.go | 3 ++ modules/renderplugin/manifest.go | 29 +++++++------- routers/web/renderplugin/assets.go | 2 +- services/renderplugin/service.go | 20 +++++----- templates/admin/navbar.tmpl | 39 +++++++------------ 5 files changed, 44 insertions(+), 49 deletions(-) diff --git a/contrib/render-plugins/example-wasm/wasm/main.go b/contrib/render-plugins/example-wasm/wasm/main.go index a43eb0aa2c..ef53fd9e9a 100644 --- a/contrib/render-plugins/example-wasm/wasm/main.go +++ b/contrib/render-plugins/example-wasm/wasm/main.go @@ -1,3 +1,6 @@ +//go:build js && wasm +// +build js,wasm + package main import ( diff --git a/modules/renderplugin/manifest.go b/modules/renderplugin/manifest.go index 65ca6a5829..7866fda070 100644 --- a/modules/renderplugin/manifest.go +++ b/modules/renderplugin/manifest.go @@ -4,7 +4,7 @@ package renderplugin import ( - "encoding/json" + "errors" "fmt" "os" "path/filepath" @@ -12,6 +12,7 @@ import ( "sort" "strings" + "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/util" ) @@ -33,7 +34,7 @@ type Manifest struct { // Normalize validates mandatory fields and normalizes values. func (m *Manifest) Normalize() error { if m.SchemaVersion == 0 { - return fmt.Errorf("manifest schemaVersion is required") + return errors.New("manifest schemaVersion is required") } if m.SchemaVersion != SupportedManifestVersion { return fmt.Errorf("manifest schemaVersion %d is not supported", m.SchemaVersion) @@ -44,11 +45,11 @@ func (m *Manifest) Normalize() error { } m.Name = strings.TrimSpace(m.Name) if m.Name == "" { - return fmt.Errorf("manifest name is required") + return errors.New("manifest name is required") } m.Version = strings.TrimSpace(m.Version) if m.Version == "" { - return fmt.Errorf("manifest version is required") + return errors.New("manifest version is required") } if m.Entry == "" { m.Entry = "render.js" @@ -66,7 +67,7 @@ func (m *Manifest) Normalize() error { cleanPatterns = append(cleanPatterns, pattern) } if len(cleanPatterns) == 0 { - return fmt.Errorf("manifest must declare at least one file pattern") + return errors.New("manifest must declare at least one file pattern") } sort.Strings(cleanPatterns) m.FilePatterns = cleanPatterns @@ -93,13 +94,13 @@ func LoadManifest(dir string) (*Manifest, error) { // Metadata is the public information exposed to the frontend for an enabled plugin. type Metadata struct { - ID string `json:"id"` - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description"` - Entry string `json:"entry"` - EntryURL string `json:"entryUrl"` - AssetsBase string `json:"assetsBaseUrl"` - FilePatterns []string `json:"filePatterns"` - SchemaVersion int `json:"schemaVersion"` + ID string `json:"id"` + Name string `json:"name"` + Version string `json:"version"` + Description string `json:"description"` + Entry string `json:"entry"` + EntryURL string `json:"entryUrl"` + AssetsBase string `json:"assetsBaseUrl"` + FilePatterns []string `json:"filePatterns"` + SchemaVersion int `json:"schemaVersion"` } diff --git a/routers/web/renderplugin/assets.go b/routers/web/renderplugin/assets.go index 6dbeb2a4a9..2423267cf9 100644 --- a/routers/web/renderplugin/assets.go +++ b/routers/web/renderplugin/assets.go @@ -4,12 +4,12 @@ package renderplugin import ( - "encoding/json" "net/http" "os" "path" "strings" + "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/renderplugin" "code.gitea.io/gitea/modules/setting" diff --git a/services/renderplugin/service.go b/services/renderplugin/service.go index 39b334e5fc..b797720d28 100644 --- a/services/renderplugin/service.go +++ b/services/renderplugin/service.go @@ -109,14 +109,14 @@ func BuildMetadata(ctx context.Context) ([]renderplugin.Metadata, error) { } assetsBase := base + plug.Identifier + "/" metas = append(metas, renderplugin.Metadata{ - ID: plug.Identifier, - Name: plug.Name, - Version: plug.Version, - Description: plug.Description, - Entry: plug.Entry, - EntryURL: assetsBase + plug.Entry, - AssetsBase: assetsBase, - FilePatterns: append([]string(nil), plug.FilePatterns...), + ID: plug.Identifier, + Name: plug.Name, + Version: plug.Version, + Description: plug.Description, + Entry: plug.Entry, + EntryURL: assetsBase + plug.Entry, + AssetsBase: assetsBase, + FilePatterns: append([]string(nil), plug.FilePatterns...), SchemaVersion: plug.FormatVersion, }) } @@ -216,7 +216,7 @@ func findManifest(root string) (string, error) { } if strings.EqualFold(d.Name(), "manifest.json") { if manifestPath != "" { - return fmt.Errorf("multiple manifest.json files found") + return errors.New("multiple manifest.json files found") } manifestPath = path } @@ -257,7 +257,7 @@ func uploadPluginDir(identifier, src string) error { return nil } if d.Type()&os.ModeSymlink != 0 { - return fmt.Errorf("symlinks are not supported inside plugin archives") + return errors.New("symlinks are not supported inside plugin archives") } rel, err := filepath.Rel(src, path) if err != nil { diff --git a/templates/admin/navbar.tmpl b/templates/admin/navbar.tmpl index 03c46feba9..0e08633f5d 100644 --- a/templates/admin/navbar.tmpl +++ b/templates/admin/navbar.tmpl @@ -38,39 +38,30 @@ {{ctx.Locale.Tr "packages.title"}} {{end}} - - {{ctx.Locale.Tr "admin.render_plugins"}} - {{ctx.Locale.Tr "admin.repositories"}} - {{if and (not DisableWebhooks) .EnableOAuth2}} -
- {{ctx.Locale.Tr "admin.integrations"}} - +
{{if .EnableActions}}
{{ctx.Locale.Tr "actions.actions"}}