From c09b52dfd631ed9929dc0a859f126a1e0efa5548 Mon Sep 17 00:00:00 2001 From: Amolith Date: Thu, 27 Mar 2025 12:53:14 -0600 Subject: [PATCH] refactor(git): refactor out named returns --- git/git.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/git/git.go b/git/git.go index 2919203b2f53f611a429b6a740e7c0621cf24387..74eb277e55c75220aefda87357503dcfe5d153e5 100644 --- a/git/git.go +++ b/git/git.go @@ -106,13 +106,13 @@ func GetReleases(gitURI, forge string) ([]Release, error) { } // minimalClone clones a repository with a depth of 1 and no checkout. -func minimalClone(url string) (r *git.Repository, err error) { +func minimalClone(url string) (*git.Repository, error) { path, err := stringifyRepo(url) if err != nil { return nil, err } - r, err = git.PlainOpen(path) + r, err := git.PlainOpen(path) if err == nil { err = r.Fetch(&git.FetchOptions{ RemoteName: "origin", @@ -137,7 +137,7 @@ func minimalClone(url string) (r *git.Repository, err error) { } // RemoveRepo removes a repository from the local filesystem. -func RemoveRepo(url string) (err error) { +func RemoveRepo(url string) error { path, err := stringifyRepo(url) if err != nil { return err @@ -168,7 +168,7 @@ func RemoveRepo(url string) (err error) { // stringifyRepo accepts a repository URI string and the corresponding local // filesystem path, whether the URI is HTTP, HTTPS, or SSH. -func stringifyRepo(url string) (path string, err error) { +func stringifyRepo(url string) (string, error) { url = strings.TrimSuffix(url, ".git") url = strings.TrimSuffix(url, "/") @@ -181,7 +181,6 @@ func stringifyRepo(url string) (path string, err error) { return "data/" + strings.Split(url, "://")[1], nil } else if ep.Protocol == "ssh" { return "data/" + ep.Host + "/" + ep.Path, nil - } else { - return "", errors.New("unsupported protocol") } + return "", errors.New("unsupported protocol") }