mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-19 09:45:24 +02: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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
package renderplugin
|
package renderplugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -12,6 +12,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ type Manifest struct {
|
|||||||
// Normalize validates mandatory fields and normalizes values.
|
// Normalize validates mandatory fields and normalizes values.
|
||||||
func (m *Manifest) Normalize() error {
|
func (m *Manifest) Normalize() error {
|
||||||
if m.SchemaVersion == 0 {
|
if m.SchemaVersion == 0 {
|
||||||
return fmt.Errorf("manifest schemaVersion is required")
|
return errors.New("manifest schemaVersion is required")
|
||||||
}
|
}
|
||||||
if m.SchemaVersion != SupportedManifestVersion {
|
if m.SchemaVersion != SupportedManifestVersion {
|
||||||
return fmt.Errorf("manifest schemaVersion %d is not supported", m.SchemaVersion)
|
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)
|
m.Name = strings.TrimSpace(m.Name)
|
||||||
if 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)
|
m.Version = strings.TrimSpace(m.Version)
|
||||||
if m.Version == "" {
|
if m.Version == "" {
|
||||||
return fmt.Errorf("manifest version is required")
|
return errors.New("manifest version is required")
|
||||||
}
|
}
|
||||||
if m.Entry == "" {
|
if m.Entry == "" {
|
||||||
m.Entry = "render.js"
|
m.Entry = "render.js"
|
||||||
@ -66,7 +67,7 @@ func (m *Manifest) Normalize() error {
|
|||||||
cleanPatterns = append(cleanPatterns, pattern)
|
cleanPatterns = append(cleanPatterns, pattern)
|
||||||
}
|
}
|
||||||
if len(cleanPatterns) == 0 {
|
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)
|
sort.Strings(cleanPatterns)
|
||||||
m.FilePatterns = 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.
|
// Metadata is the public information exposed to the frontend for an enabled plugin.
|
||||||
type Metadata struct {
|
type Metadata struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Entry string `json:"entry"`
|
Entry string `json:"entry"`
|
||||||
EntryURL string `json:"entryUrl"`
|
EntryURL string `json:"entryUrl"`
|
||||||
AssetsBase string `json:"assetsBaseUrl"`
|
AssetsBase string `json:"assetsBaseUrl"`
|
||||||
FilePatterns []string `json:"filePatterns"`
|
FilePatterns []string `json:"filePatterns"`
|
||||||
SchemaVersion int `json:"schemaVersion"`
|
SchemaVersion int `json:"schemaVersion"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,12 @@
|
|||||||
package renderplugin
|
package renderplugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/renderplugin"
|
"code.gitea.io/gitea/modules/renderplugin"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|||||||
@ -109,14 +109,14 @@ func BuildMetadata(ctx context.Context) ([]renderplugin.Metadata, error) {
|
|||||||
}
|
}
|
||||||
assetsBase := base + plug.Identifier + "/"
|
assetsBase := base + plug.Identifier + "/"
|
||||||
metas = append(metas, renderplugin.Metadata{
|
metas = append(metas, renderplugin.Metadata{
|
||||||
ID: plug.Identifier,
|
ID: plug.Identifier,
|
||||||
Name: plug.Name,
|
Name: plug.Name,
|
||||||
Version: plug.Version,
|
Version: plug.Version,
|
||||||
Description: plug.Description,
|
Description: plug.Description,
|
||||||
Entry: plug.Entry,
|
Entry: plug.Entry,
|
||||||
EntryURL: assetsBase + plug.Entry,
|
EntryURL: assetsBase + plug.Entry,
|
||||||
AssetsBase: assetsBase,
|
AssetsBase: assetsBase,
|
||||||
FilePatterns: append([]string(nil), plug.FilePatterns...),
|
FilePatterns: append([]string(nil), plug.FilePatterns...),
|
||||||
SchemaVersion: plug.FormatVersion,
|
SchemaVersion: plug.FormatVersion,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ func findManifest(root string) (string, error) {
|
|||||||
}
|
}
|
||||||
if strings.EqualFold(d.Name(), "manifest.json") {
|
if strings.EqualFold(d.Name(), "manifest.json") {
|
||||||
if manifestPath != "" {
|
if manifestPath != "" {
|
||||||
return fmt.Errorf("multiple manifest.json files found")
|
return errors.New("multiple manifest.json files found")
|
||||||
}
|
}
|
||||||
manifestPath = path
|
manifestPath = path
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ func uploadPluginDir(identifier, src string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if d.Type()&os.ModeSymlink != 0 {
|
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)
|
rel, err := filepath.Rel(src, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -38,39 +38,30 @@
|
|||||||
{{ctx.Locale.Tr "packages.title"}}
|
{{ctx.Locale.Tr "packages.title"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{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">
|
<a class="{{if .PageIsAdminRepositories}}active {{end}}item" href="{{AppSubUrl}}/-/admin/repos">
|
||||||
{{ctx.Locale.Tr "admin.repositories"}}
|
{{ctx.Locale.Tr "admin.repositories"}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<!-- Webhooks and OAuth can be both disabled here, so add this if statement to display different ui -->
|
<!-- 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 .PageIsAdminRenderPlugins}}open{{end}}>
|
||||||
<details class="item toggleable-item" {{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks .PageIsAdminApplications}}open{{end}}>
|
<summary>{{ctx.Locale.Tr "admin.integrations"}}</summary>
|
||||||
<summary>{{ctx.Locale.Tr "admin.integrations"}}</summary>
|
<div class="menu">
|
||||||
<div class="menu">
|
<a class="{{if .PageIsAdminRenderPlugins}}active {{end}}item" href="{{AppSubUrl}}/-/admin/render-plugins">
|
||||||
<a class="{{if .PageIsAdminApplications}}active {{end}}item" href="{{AppSubUrl}}/-/admin/applications">
|
{{ctx.Locale.Tr "admin.render_plugins"}}
|
||||||
{{ctx.Locale.Tr "settings.applications"}}
|
</a>
|
||||||
</a>
|
{{if not DisableWebhooks}}
|
||||||
<a class="{{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks}}active {{end}}item" href="{{AppSubUrl}}/-/admin/hooks">
|
<a class="{{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks}}active {{end}}item" href="{{AppSubUrl}}/-/admin/hooks">
|
||||||
{{ctx.Locale.Tr "admin.hooks"}}
|
{{ctx.Locale.Tr "admin.hooks"}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
{{end}}
|
||||||
</details>
|
{{if .EnableOAuth2}}
|
||||||
{{else}}
|
<a class="{{if .PageIsAdminApplications}}active {{end}}item" href="{{AppSubUrl}}/-/admin/applications">
|
||||||
{{if not DisableWebhooks}}
|
{{ctx.Locale.Tr "settings.applications"}}
|
||||||
<a class="{{if or .PageIsAdminDefaultHooks .PageIsAdminSystemHooks}}active {{end}}item" href="{{AppSubUrl}}/-/admin/hooks">
|
</a>
|
||||||
{{ctx.Locale.Tr "admin.hooks"}}
|
{{end}}
|
||||||
</a>
|
</div>
|
||||||
{{end}}
|
</details>
|
||||||
{{if .EnableOAuth2}}
|
|
||||||
<a class="{{if .PageIsAdminApplications}}active {{end}}item" href="{{AppSubUrl}}/-/admin/applications">
|
|
||||||
{{ctx.Locale.Tr "settings.applications"}}
|
|
||||||
</a>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
{{if .EnableActions}}
|
{{if .EnableActions}}
|
||||||
<details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsVariables}}open{{end}}>
|
<details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsVariables}}open{{end}}>
|
||||||
<summary>{{ctx.Locale.Tr "actions.actions"}}</summary>
|
<summary>{{ctx.Locale.Tr "actions.actions"}}</summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user