2
0

fix: Go linter issues in v2 API
Some checks are pending
Build and Release / Lint (push) Waiting to run
Build and Release / Unit Tests (push) Waiting to run
Build and Release / Integration Tests (PostgreSQL) (push) Waiting to run
Build and Release / Build Binaries (amd64, darwin) (push) Blocked by required conditions
Build and Release / Build Binaries (amd64, linux) (push) Blocked by required conditions
Build and Release / Build Binaries (amd64, windows) (push) Blocked by required conditions
Build and Release / Build Binaries (arm64, darwin) (push) Blocked by required conditions
Build and Release / Build Binaries (arm64, linux) (push) Blocked by required conditions

- Remove omitempty from nested struct fields in PagesConfigResponse
- Remove unused ctx parameter from findUpdateAsset and convertToAPIRelease
- Simplify nil check for release.Attachments (len() handles nil)
- Use strings.EqualFold instead of strings.ToUpper for case-insensitive comparison

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-10 08:22:37 -05:00
parent efb82c1763
commit a7968b5ff3
3 changed files with 12 additions and 12 deletions

BIN
assets/256x256.png Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -19,10 +19,10 @@ type PagesConfigResponse struct {
PublicLanding bool `json:"public_landing"` PublicLanding bool `json:"public_landing"`
Template string `json:"template"` Template string `json:"template"`
Domain string `json:"domain,omitempty"` Domain string `json:"domain,omitempty"`
Branding pages_module.BrandingConfig `json:"branding,omitempty"` Branding pages_module.BrandingConfig `json:"branding"`
Hero pages_module.HeroConfig `json:"hero,omitempty"` Hero pages_module.HeroConfig `json:"hero"`
SEO pages_module.SEOConfig `json:"seo,omitempty"` SEO pages_module.SEOConfig `json:"seo"`
Footer pages_module.FooterConfig `json:"footer,omitempty"` Footer pages_module.FooterConfig `json:"footer"`
} }
// PagesContentResponse represents the rendered content for a landing page // PagesContentResponse represents the rendered content for a landing page

View File

@@ -150,7 +150,7 @@ func CheckAppUpdate(ctx *context.APIContext) {
} }
// Find the appropriate asset for this platform/arch // Find the appropriate asset for this platform/arch
downloadURL, platformInfo := findUpdateAsset(ctx, latestRelease, platform, arch) downloadURL, platformInfo := findUpdateAsset(latestRelease, platform, arch)
if downloadURL == "" { if downloadURL == "" {
// No compatible asset found // No compatible asset found
ctx.Status(http.StatusNoContent) ctx.Status(http.StatusNoContent)
@@ -169,8 +169,8 @@ func CheckAppUpdate(ctx *context.APIContext) {
} }
// findUpdateAsset finds the appropriate download asset for the given platform and architecture // findUpdateAsset finds the appropriate download asset for the given platform and architecture
func findUpdateAsset(ctx *context.APIContext, release *repo_model.Release, platform, arch string) (string, *PlatformInfo) { func findUpdateAsset(release *repo_model.Release, platform, arch string) (string, *PlatformInfo) {
if release.Attachments == nil || len(release.Attachments) == 0 { if len(release.Attachments) == 0 {
return "", nil return "", nil
} }
@@ -199,7 +199,7 @@ func findUpdateAsset(ctx *context.APIContext, release *repo_model.Release, platf
// For Windows, also look for RELEASES file // For Windows, also look for RELEASES file
if platform == "windows" { if platform == "windows" {
for _, a := range release.Attachments { for _, a := range release.Attachments {
if strings.ToUpper(a.Name) == "RELEASES" { if strings.EqualFold(a.Name, "RELEASES") {
platformInfo.ReleasesURL = fmt.Sprintf("%s%s/%s/releases/download/%s/%s", platformInfo.ReleasesURL = fmt.Sprintf("%s%s/%s/releases/download/%s/%s",
setting.AppURL, setting.AppURL,
release.Repo.OwnerName, release.Repo.OwnerName,
@@ -346,7 +346,7 @@ func ListReleasesV2(ctx *context.APIContext) {
// Convert to API format // Convert to API format
apiReleases := make([]*api.Release, 0, len(releases)) apiReleases := make([]*api.Release, 0, len(releases))
for _, release := range releases { for _, release := range releases {
apiReleases = append(apiReleases, convertToAPIRelease(ctx, repo, release)) apiReleases = append(apiReleases, convertToAPIRelease(repo, release))
} }
ctx.JSON(http.StatusOK, apiReleases) ctx.JSON(http.StatusOK, apiReleases)
@@ -388,7 +388,7 @@ func GetReleaseV2(ctx *context.APIContext) {
return return
} }
ctx.JSON(http.StatusOK, convertToAPIRelease(ctx, repo, release)) ctx.JSON(http.StatusOK, convertToAPIRelease(repo, release))
} }
// GetLatestReleaseV2 gets the latest release // GetLatestReleaseV2 gets the latest release
@@ -436,11 +436,11 @@ func GetLatestReleaseV2(ctx *context.APIContext) {
return return
} }
ctx.JSON(http.StatusOK, convertToAPIRelease(ctx, repo, release)) ctx.JSON(http.StatusOK, convertToAPIRelease(repo, release))
} }
// convertToAPIRelease converts a repo_model.Release to api.Release // convertToAPIRelease converts a repo_model.Release to api.Release
func convertToAPIRelease(ctx *context.APIContext, repo *repo_model.Repository, release *repo_model.Release) *api.Release { func convertToAPIRelease(repo *repo_model.Repository, release *repo_model.Release) *api.Release {
assets := make([]*api.Attachment, 0, len(release.Attachments)) assets := make([]*api.Attachment, 0, len(release.Attachments))
for _, attachment := range release.Attachments { for _, attachment := range release.Attachments {
assets = append(assets, &api.Attachment{ assets = append(assets, &api.Attachment{