From 3da7efda912a7f7b37d83dd8db0ce7c0a9b11158 Mon Sep 17 00:00:00 2001 From: Amolith Date: Thu, 27 Mar 2025 13:30:36 -0600 Subject: [PATCH] refactor(git): swap if-else chain for switch statement --- git/git.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/git/git.go b/git/git.go index 74eb277e55c75220aefda87357503dcfe5d153e5..db7d8391938eb4dbfebc6afaaad0ddaba0a5d6d3 100644 --- a/git/git.go +++ b/git/git.go @@ -177,10 +177,12 @@ func stringifyRepo(url string) (string, error) { return "", err } - if ep.Protocol == "http" || ep.Protocol == "https" { + switch ep.Protocol { + case "http", "https": return "data/" + strings.Split(url, "://")[1], nil - } else if ep.Protocol == "ssh" { + case "ssh": return "data/" + ep.Host + "/" + ep.Path, nil + default: + return "", errors.New("unsupported protocol") } - return "", errors.New("unsupported protocol") }