From 6608d0aa8c287e4c2f1430897738f99c04dc0995 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 50e26d26..1acd95e1 100644 --- a/params/params.go +++ b/params/params.go @@ -1170,18 +1170,13 @@ func (g ForgeEntity) GetForgeType() (EndpointType, error) { } func (g ForgeEntity) ForgeURL() string { - switch g.Credentials.ForgeType { - case GiteaEndpointType: - return g.Credentials.Endpoint.APIBaseURL - default: - switch g.EntityType { - case ForgeEntityTypeRepository: - return fmt.Sprintf("%s/%s/%s", g.Credentials.BaseURL, g.Owner, g.Name) - case ForgeEntityTypeOrganization: - return fmt.Sprintf("%s/%s", g.Credentials.BaseURL, g.Owner) - case ForgeEntityTypeEnterprise: - return fmt.Sprintf("%s/enterprises/%s", g.Credentials.BaseURL, g.Owner) - } + switch g.EntityType { + case ForgeEntityTypeRepository: + return fmt.Sprintf("%s/%s/%s", g.Credentials.BaseURL, g.Owner, g.Name) + case ForgeEntityTypeOrganization: + return fmt.Sprintf("%s/%s", g.Credentials.BaseURL, g.Owner) + case ForgeEntityTypeEnterprise: + return fmt.Sprintf("%s/enterprises/%s", g.Credentials.BaseURL, g.Owner) } return "" }