mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-04 22:57:34 -04:00
Adds additional NuGet package information, particularly IconURL
, to bring the Gitea NuGet api more in-line with GitHub's NuGet API.
This allows fixes #21291, allowing icons to appear for NuGet packages from inside Visual Studio.
This commit is contained in:
parent
dd1fd89185
commit
343d9127c0
@ -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)
|
||||
|
@ -71,6 +71,7 @@ type Metadata struct {
|
||||
ReleaseNotes string `json:"release_notes,omitempty"`
|
||||
RepositoryURL string `json:"repository_url,omitempty"`
|
||||
RequireLicenseAcceptance bool `json:"require_license_acceptance"`
|
||||
Summary string `json:"summary,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
|
||||
@ -105,6 +106,7 @@ type nuspecPackage struct {
|
||||
Readme string `xml:"readme"`
|
||||
ReleaseNotes string `xml:"releaseNotes"`
|
||||
RequireLicenseAcceptance bool `xml:"requireLicenseAcceptance"`
|
||||
Summary string `xml:"summary"`
|
||||
Tags string `xml:"tags"`
|
||||
Title string `xml:"title"`
|
||||
|
||||
@ -204,6 +206,7 @@ func ParseNuspecMetaData(archive *zip.Reader, r io.Reader) (*Package, error) {
|
||||
ReleaseNotes: p.Metadata.ReleaseNotes,
|
||||
RepositoryURL: p.Metadata.Repository.URL,
|
||||
RequireLicenseAcceptance: p.Metadata.RequireLicenseAcceptance,
|
||||
Summary: p.Metadata.Summary,
|
||||
Tags: p.Metadata.Tags,
|
||||
Title: p.Metadata.Title,
|
||||
|
||||
|
@ -60,7 +60,8 @@ type CatalogEntry struct {
|
||||
ReleaseNotes string `json:"releaseNotes"`
|
||||
Authors string `json:"authors"`
|
||||
RequireLicenseAcceptance bool `json:"requireLicenseAcceptance"`
|
||||
ProjectURL string `json:"projectURL"`
|
||||
ProjectURL string `json:"projectUrl"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
DependencyGroups []*PackageDependencyGroup `json:"dependencyGroups"`
|
||||
}
|
||||
|
||||
@ -116,7 +117,9 @@ func createRegistrationIndexPageItem(l *linkBuilder, pd *packages_model.PackageD
|
||||
Description: metadata.Description,
|
||||
ReleaseNotes: metadata.ReleaseNotes,
|
||||
Authors: metadata.Authors,
|
||||
RequireLicenseAcceptance: metadata.RequireLicenseAcceptance,
|
||||
ProjectURL: metadata.ProjectURL,
|
||||
IconURL: metadata.IconURL,
|
||||
DependencyGroups: createDependencyGroups(pd),
|
||||
},
|
||||
}
|
||||
@ -188,12 +191,21 @@ type SearchResultResponse struct {
|
||||
|
||||
// https://docs.microsoft.com/en-us/nuget/api/search-query-service-resource#search-result
|
||||
type SearchResult struct {
|
||||
Authors string `json:"authors"`
|
||||
Copyright string `json:"copyright"`
|
||||
Description string `json:"description"`
|
||||
IconURL string `json:"iconUrl"`
|
||||
ID string `json:"id"`
|
||||
IsPrerelease bool `json:"isPrerelease"`
|
||||
Language string `json:"language"`
|
||||
LicenseURL string `json:"licenseUrl"`
|
||||
ProjectURL string `json:"projectUrl"`
|
||||
RequireLicenseAcceptance bool `json:"requireLicenseAcceptance"`
|
||||
Summary string `json:"summary"`
|
||||
Tags string `json:"tags"`
|
||||
Title string `json:"title"`
|
||||
Version string `json:"version"`
|
||||
Versions []*SearchResultVersion `json:"versions"`
|
||||
Description string `json:"description"`
|
||||
Authors string `json:"authors"`
|
||||
ProjectURL string `json:"projectURL"`
|
||||
RegistrationIndexURL string `json:"registration"`
|
||||
}
|
||||
|
||||
@ -244,12 +256,21 @@ func createSearchResult(l *linkBuilder, pds []*packages_model.PackageDescriptor)
|
||||
metadata := latest.Metadata.(*nuget_module.Metadata)
|
||||
|
||||
return &SearchResult{
|
||||
Authors: metadata.Authors,
|
||||
Copyright: metadata.Copyright,
|
||||
Description: metadata.Description,
|
||||
IconURL: metadata.IconURL,
|
||||
ID: latest.Package.Name,
|
||||
IsPrerelease: latest.Version.IsPrerelease(),
|
||||
Language: metadata.Language,
|
||||
LicenseURL: metadata.LicenseURL,
|
||||
ProjectURL: metadata.ProjectURL,
|
||||
RequireLicenseAcceptance: metadata.RequireLicenseAcceptance,
|
||||
Summary: metadata.Summary,
|
||||
Tags: metadata.Tags,
|
||||
Title: metadata.Title,
|
||||
Version: latest.Version.Version,
|
||||
Versions: versions,
|
||||
Description: metadata.Description,
|
||||
Authors: metadata.Authors,
|
||||
ProjectURL: metadata.ProjectURL,
|
||||
RegistrationIndexURL: l.GetRegistrationIndexURL(latest.Package.Name),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user