From daeb9127764fc9dd469294f755e277fdfca09a00 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Wed, 10 Jun 2026 00:07:56 +0200 Subject: rtree: add support for multiple URLs per remote This requires changing the index format, which I'm using as an opportunity to: - move from YAML to JSON (so I can maybe kill the YAML parser dependency at some point) - move the index file into standard XDG paths --- internal/rtree/remote.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'internal/rtree/remote.go') diff --git a/internal/rtree/remote.go b/internal/rtree/remote.go index afcdf9b..8c355a8 100644 --- a/internal/rtree/remote.go +++ b/internal/rtree/remote.go @@ -4,6 +4,7 @@ package rtree import ( + "encoding/json" "net/url" "path/filepath" "regexp" @@ -86,16 +87,16 @@ func (u RemoteURL) CheckoutPath() (string, error) { return filepath.Join(parsed.Hostname(), parsed.Path), nil } -// MarshalYAML implements the yaml.Marshaler interface. -func (u RemoteURL) MarshalYAML() (any, error) { +// MarshalJSON implements the json.Marshaler interface. +func (u RemoteURL) MarshalJSON() ([]byte, error) { //store URLs in the index in the canonical format - return u.CanonicalURL(), nil + return json.Marshal(u.CanonicalURL()) } -// UnmarshalYAML implements the yaml.Unmarshaler interface. -func (u *RemoteURL) UnmarshalYAML(unmarshal func(any) error) error { +// UnmarshalJSON implements the json.Unmarshaler interface. +func (u *RemoteURL) UnmarshalJSON(buf []byte) error { var s string - err := unmarshal(&s) + err := json.Unmarshal(buf, &s) if err == nil { *u = ParseRemoteURL(s) } -- cgit v1.3.1