Improve NuGet API Parity (#21291) (#34940)
Some checks failed
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-docker-rootful (push) Has been cancelled
release-nightly / nightly-docker-rootless (push) Has been cancelled
cron-translations / crowdin-pull (push) Has been cancelled

Fixes #21291, allowing icons and other missing attributes to appear for
NuGet packages from inside Visual Studio like they do with GitHub Nuget
packages.

Adds additional NuGet package information, particularly `IconURL`, to
bring the Gitea NuGet API more in-line with GitHub's NuGet API.

ref: https://learn.microsoft.com/en-us/nuget/api/search-query-service-resource
This commit is contained in:
Scion
2025-07-07 03:43:58 -07:00
committed by GitHub
parent ddfa2e4a3e
commit f88800d545
4 changed files with 184 additions and 59 deletions

View File

@@ -37,6 +37,14 @@ type PackageVersion struct {
DownloadCount int64 `xorm:"NOT NULL DEFAULT 0"`
}
// IsPrerelease checks if the version is a prerelease version according to semantic versioning
func (pv *PackageVersion) IsPrerelease() bool {
if pv == nil || pv.Version == "" {
return false
}
return strings.Contains(pv.Version, "-")
}
// GetOrInsertVersion inserts a version. If the same version exist already ErrDuplicatePackageVersion is returned
func GetOrInsertVersion(ctx context.Context, pv *PackageVersion) (*PackageVersion, error) {
e := db.GetEngine(ctx)