mirror of
https://github.com/go-gitea/gitea
synced 2024-11-19 16:44:25 +00:00
Fix tautological conditions
This commit is contained in:
parent
7b8e418da1
commit
52c003acd7
@ -117,16 +117,14 @@ 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 {
|
log.Error("Failed to open repository: %s/%s Error: %v", ownerName, repoName, err)
|
||||||
log.Error("Failed to open repository: %s/%s Error: %v", ownerName, repoName, err)
|
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
|
||||||
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
|
Err: fmt.Sprintf("Failed to open repository: %s/%s Error: %v", ownerName, repoName, err),
|
||||||
Err: fmt.Sprintf("Failed to open repository: %s/%s Error: %v", ownerName, repoName, err),
|
})
|
||||||
})
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user