1
1
mirror of https://github.com/go-gitea/gitea synced 2024-10-02 09:14:05 +00:00

Fix tautological conditions

This commit is contained in:
silverwind 2024-04-27 19:04:00 +02:00
parent 7b8e418da1
commit 52c003acd7
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
3 changed files with 17 additions and 17 deletions

View File

@ -117,7 +117,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
} }
} }
if len(branchesToSync) > 0 { if len(branchesToSync) > 0 {
if gitRepo == nil {
var err error var err error
gitRepo, err = gitrepo.OpenRepository(ctx, repo) gitRepo, err = gitrepo.OpenRepository(ctx, repo)
if err != nil { if err != nil {
@ -127,7 +126,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
}) })
return return
} }
}
var ( var (
branchNames = make([]string, 0, len(branchesToSync)) branchNames = make([]string, 0, len(branchesToSync))

View File

@ -182,7 +182,7 @@ func createProvider(providerName string, source *Source) (goth.Provider, error)
} }
// always set the name if provider is created so we can support multiple setups of 1 provider // always set the name if provider is created so we can support multiple setups of 1 provider
if err == nil && provider != nil { if provider != nil {
provider.SetName(providerName) provider.SetName(providerName)
} }

View File

@ -211,13 +211,11 @@ func ToLabel(label *issues_model.Label, repo *repo_model.Repository, org *user_m
IsArchived: label.IsArchived(), IsArchived: label.IsArchived(),
} }
labelBelongsToRepo := label.BelongsToRepo()
// calculate URL // calculate URL
if label.BelongsToRepo() && repo != nil { if labelBelongsToRepo && repo != nil {
if repo != nil {
result.URL = fmt.Sprintf("%s/labels/%d", repo.APIURL(), label.ID) result.URL = fmt.Sprintf("%s/labels/%d", repo.APIURL(), label.ID)
} else {
log.Error("ToLabel did not get repo to calculate url for label with id '%d'", label.ID)
}
} else { // BelongsToOrg } else { // BelongsToOrg
if org != nil { if org != nil {
result.URL = fmt.Sprintf("%sapi/v1/orgs/%s/labels/%d", setting.AppURL, url.PathEscape(org.Name), label.ID) result.URL = fmt.Sprintf("%sapi/v1/orgs/%s/labels/%d", setting.AppURL, url.PathEscape(org.Name), label.ID)
@ -226,6 +224,10 @@ func ToLabel(label *issues_model.Label, repo *repo_model.Repository, org *user_m
} }
} }
if labelBelongsToRepo && repo == nil {
log.Error("ToLabel did not get repo to calculate url for label with id '%d'", label.ID)
}
return result return result
} }