mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package maven
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"strings"
|
|
|
|
packages_model "github.com/hanzoai/git/models/packages"
|
|
)
|
|
|
|
// MetadataResponse https://maven.apache.org/ref/3.2.5/maven-repository-metadata/repository-metadata.html
|
|
type MetadataResponse struct {
|
|
XMLName xml.Name `xml:"metadata"`
|
|
GroupID string `xml:"groupId"`
|
|
ArtifactID string `xml:"artifactId"`
|
|
Release string `xml:"versioning>release,omitempty"`
|
|
Latest string `xml:"versioning>latest"`
|
|
Version []string `xml:"versioning>versions>version"`
|
|
}
|
|
|
|
// pds is expected to be sorted ascending by CreatedUnix
|
|
func createMetadataResponse(pds []*packages_model.PackageDescriptor, groupID, artifactID string) *MetadataResponse {
|
|
var release *packages_model.PackageDescriptor
|
|
|
|
versions := make([]string, 0, len(pds))
|
|
for _, pd := range pds {
|
|
if !strings.HasSuffix(pd.Version.Version, "-SNAPSHOT") {
|
|
release = pd
|
|
}
|
|
versions = append(versions, pd.Version.Version)
|
|
}
|
|
|
|
latest := pds[len(pds)-1]
|
|
|
|
resp := &MetadataResponse{
|
|
GroupID: groupID,
|
|
ArtifactID: artifactID,
|
|
Latest: latest.Version.Version,
|
|
Version: versions,
|
|
}
|
|
if release != nil {
|
|
resp.Release = release.Version.Version
|
|
}
|
|
return resp
|
|
}
|