From 8f1cd9f97497932af9330e32ad84a933ff1bcd24 Mon Sep 17 00:00:00 2001 From: Daniel Sy Date: Wed, 27 Aug 2025 16:04:56 +0200 Subject: [PATCH] =?UTF-8?q?refactor(params):=20=E2=99=BB=EF=B8=8F=20Simpli?= =?UTF-8?q?fy=20ForgeURL=20logic=20by=20removing=20redundant=20switch=20ca?= =?UTF-8?q?se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Streamlines the ForgeURL method by removing an unnecessary nested switch case on ForgeType, consolidating the logic to rely solely on EntityType. This change reduces complexity and improves code readability without altering functionality. --- params/params.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/params/params.go b/params/params.go index 30df70c0..020e66d4 100644 --- a/params/params.go +++ b/params/params.go @@ -1377,18 +1377,13 @@ func (g ForgeEntity) GetForgeType() (EndpointType, error) { func (g ForgeEntity) ForgeURL() string { baseURL := strings.TrimRight(g.Credentials.BaseURL, "/") - switch g.Credentials.ForgeType { - case GiteaEndpointType: - return g.Credentials.Endpoint.APIBaseURL - default: - switch g.EntityType { - case ForgeEntityTypeRepository: - return fmt.Sprintf("%s/%s/%s", baseURL, g.Owner, g.Name) - case ForgeEntityTypeOrganization: - return fmt.Sprintf("%s/%s", baseURL, g.Owner) - case ForgeEntityTypeEnterprise: - return fmt.Sprintf("%s/enterprises/%s", baseURL, g.Owner) - } + switch g.EntityType { + case ForgeEntityTypeRepository: + return fmt.Sprintf("%s/%s/%s", baseURL, g.Owner, g.Name) + case ForgeEntityTypeOrganization: + return fmt.Sprintf("%s/%s", baseURL, g.Owner) + case ForgeEntityTypeEnterprise: + return fmt.Sprintf("%s/enterprises/%s", baseURL, g.Owner) } return "" }