0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-23 08:35:34 +02:00

remove redundant return value from fillPathParts

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-11-23 17:33:11 -05:00
parent 1e9bf82454
commit b2d3590547
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -123,7 +123,7 @@ func ParseRepositoryURL(ctx context.Context, repoURL string) (*RepositoryURL, er
ret := &RepositoryURL{} ret := &RepositoryURL{}
ret.GitURL = parsed ret.GitURL = parsed
fillPathParts := func(s string) error { fillPathParts := func(s string) {
s = strings.TrimPrefix(s, "/") s = strings.TrimPrefix(s, "/")
fields := strings.SplitN(s, "/", 4) fields := strings.SplitN(s, "/", 4)
var pathErr error var pathErr error
@ -134,7 +134,7 @@ func ParseRepositoryURL(ctx context.Context, repoURL string) (*RepositoryURL, er
if pathErr != nil { if pathErr != nil {
ret.RepoName = strings.TrimSuffix(fields[1], ".git") ret.RepoName = strings.TrimSuffix(fields[1], ".git")
ret.RemainingPath = "/" + fields[2] ret.RemainingPath = "/" + fields[2]
return nil return
} }
ret.RepoName = strings.TrimSuffix(fields[2], ".git") ret.RepoName = strings.TrimSuffix(fields[2], ".git")
if len(fields) >= 4 { if len(fields) >= 4 {
@ -142,7 +142,7 @@ func ParseRepositoryURL(ctx context.Context, repoURL string) (*RepositoryURL, er
} }
} }
} }
return nil return
} }
switch parsed.URL.Scheme { switch parsed.URL.Scheme {
@ -150,9 +150,7 @@ func ParseRepositoryURL(ctx context.Context, repoURL string) (*RepositoryURL, er
if !httplib.IsCurrentGiteaSiteURL(ctx, repoURL) { if !httplib.IsCurrentGiteaSiteURL(ctx, repoURL) {
return ret, nil return ret, nil
} }
if err = fillPathParts(strings.TrimPrefix(parsed.URL.Path, setting.AppSubURL)); err != nil { fillPathParts(strings.TrimPrefix(parsed.URL.Path, setting.AppSubURL))
return nil, err
}
case "ssh", "git+ssh": case "ssh", "git+ssh":
domainSSH := setting.SSH.Domain domainSSH := setting.SSH.Domain
domainCur := httplib.GuessCurrentHostDomain(ctx) domainCur := httplib.GuessCurrentHostDomain(ctx)
@ -166,9 +164,7 @@ func ParseRepositoryURL(ctx context.Context, repoURL string) (*RepositoryURL, er
// check whether URL domain is current domain from context // check whether URL domain is current domain from context
domainMatches = domainMatches || (domainCur != "" && domainCur == urlDomain) domainMatches = domainMatches || (domainCur != "" && domainCur == urlDomain)
if domainMatches { if domainMatches {
if err = fillPathParts(parsed.URL.Path); err != nil { fillPathParts(parsed.URL.Path)
return nil, err
}
} }
} }
return ret, nil return ret, nil