refactor(params): ♻️ Simplify ForgeURL logic by removing redundant switch case
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.
This commit is contained in:
parent
90fe8c9a57
commit
8f1cd9f974
1 changed files with 7 additions and 12 deletions
|
|
@ -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 ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue