From 2597c03d1555e00dec59830b7de75e7090208e05 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Wed, 2 Oct 2024 16:49:36 -0500 Subject: config: Use TOML TOML is simple for users, and it is used in notably projects like rustlang. It also provides comments! --- internal/github/filesystem.go | 9 +++++---- internal/github/github.go | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'internal/github') diff --git a/internal/github/filesystem.go b/internal/github/filesystem.go index 3f069b4..219ec5d 100644 --- a/internal/github/filesystem.go +++ b/internal/github/filesystem.go @@ -2,13 +2,14 @@ package github import ( "fmt" - "net/url" "os" "path" "strings" + + "git.server.ky/slackcoder/mirror/internal" ) -func listReleasesByTagName(dst *url.URL) ([]string, error) { +func listReleasesByTagName(dst *internal.URL) ([]string, error) { entries, err := os.ReadDir(dst.Path) if err != nil { return nil, err @@ -23,7 +24,7 @@ func listReleasesByTagName(dst *url.URL) ([]string, error) { } // The path which project release assets are saved. -func localReleaseFilePath(dst *url.URL, tagName string) string { +func localReleaseFilePath(dst *internal.URL, tagName string) string { return path.Join(dst.Path, tagName) } @@ -46,7 +47,7 @@ func releaseSourceFileName(project string, tagName string, ext string) string { return fmt.Sprintf("%s-%s.%s", project, releaseName(tagName), ext) } -func removeRelease(dst *url.URL, tagName string) error { +func removeRelease(dst *internal.URL, tagName string) error { fp := localReleaseFilePath(dst, tagName) return os.RemoveAll(fp) } diff --git a/internal/github/github.go b/internal/github/github.go index bf35a6a..b2b1987 100644 --- a/internal/github/github.go +++ b/internal/github/github.go @@ -4,12 +4,13 @@ import ( "fmt" "io" "net/http" - "net/url" "os" "path" "path/filepath" "regexp" "time" + + "git.server.ky/slackcoder/mirror/internal" ) type Client struct { @@ -192,7 +193,7 @@ func (c *Client) download(dst string, src string) error { return nil } -func (c *Client) MirrorAssets(dst *url.URL, src *url.URL) error { +func (c *Client) MirrorAssets(dst *internal.URL, src *internal.URL) error { if src.Hostname() != "github.com" { return fmt.Errorf("host must be github.com") } -- cgit v1.2.3