mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-09 04:41:48 +01:00
Fix lint
This commit is contained in:
parent
2c56b90cd4
commit
75fd8b5b3e
@ -1,3 +1,6 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
||||
@ -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"`
|
||||
}
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -38,39 +38,30 @@
|
||||
{{ctx.Locale.Tr "packages.title"}}
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="{{if .PageIsAdminRenderPlugins}}active {{end}}item" href="{{AppSubUrl}}/-/admin/render-plugins">
|
||||
{{ctx.Locale.Tr "admin.render_plugins"}}
|
||||
</a>
|
||||
<a class="{{if .PageIsAdminRepositories}}active {{end}}item" href="{{AppSubUrl}}/-/admin/repos">
|
||||
{{ctx.Locale.Tr "admin.repositories"}}
|
||||
</a>
|
||||
</div>
|
||||
</details>
|
||||
<!-- Webhooks and OAuth can be both disabled here, so add this if statement to display different ui -->
|
||||
{{if and (not DisableWebhooks) .EnableOAuth2}}
|
||||
<details class="item toggleable-item" {{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks .PageIsAdminApplications}}open{{end}}>
|
||||
<summary>{{ctx.Locale.Tr "admin.integrations"}}</summary>
|
||||
<div class="menu">
|
||||
<a class="{{if .PageIsAdminApplications}}active {{end}}item" href="{{AppSubUrl}}/-/admin/applications">
|
||||
{{ctx.Locale.Tr "settings.applications"}}
|
||||
</a>
|
||||
<details class="item toggleable-item" {{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks .PageIsAdminApplications .PageIsAdminRenderPlugins}}open{{end}}>
|
||||
<summary>{{ctx.Locale.Tr "admin.integrations"}}</summary>
|
||||
<div class="menu">
|
||||
<a class="{{if .PageIsAdminRenderPlugins}}active {{end}}item" href="{{AppSubUrl}}/-/admin/render-plugins">
|
||||
{{ctx.Locale.Tr "admin.render_plugins"}}
|
||||
</a>
|
||||
{{if not DisableWebhooks}}
|
||||
<a class="{{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks}}active {{end}}item" href="{{AppSubUrl}}/-/admin/hooks">
|
||||
{{ctx.Locale.Tr "admin.hooks"}}
|
||||
</a>
|
||||
</div>
|
||||
</details>
|
||||
{{else}}
|
||||
{{if not DisableWebhooks}}
|
||||
<a class="{{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks}}active {{end}}item" href="{{AppSubUrl}}/-/admin/hooks">
|
||||
{{ctx.Locale.Tr "admin.hooks"}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{if .EnableOAuth2}}
|
||||
<a class="{{if .PageIsAdminApplications}}active {{end}}item" href="{{AppSubUrl}}/-/admin/applications">
|
||||
{{ctx.Locale.Tr "settings.applications"}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if .EnableOAuth2}}
|
||||
<a class="{{if .PageIsAdminApplications}}active {{end}}item" href="{{AppSubUrl}}/-/admin/applications">
|
||||
{{ctx.Locale.Tr "settings.applications"}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</details>
|
||||
{{if .EnableActions}}
|
||||
<details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsVariables}}open{{end}}>
|
||||
<summary>{{ctx.Locale.Tr "actions.actions"}}</summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user