Prevent NPE due to missing repo in regression in #17551 (#17697)

tokarchuk/v1.17
zeripath 3 years ago committed by GitHub
parent 1f1ae57139
commit 878c2ce6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      models/issue.go

@ -1928,7 +1928,7 @@ func (issue *Issue) getParticipantIDsByIssue(e db.Engine) ([]int64, error) {
// Get Blocked By Dependencies, aka all issues this issue is blocked by.
func (issue *Issue) getBlockedByDependencies(e db.Engine) (issueDeps []*DependencyInfo, err error) {
return issueDeps, e.
err = e.
Table("issue").
Join("INNER", "repository", "repository.id = issue.repo_id").
Join("INNER", "issue_dependency", "issue_dependency.dependency_id = issue.id").
@ -1936,11 +1936,17 @@ func (issue *Issue) getBlockedByDependencies(e db.Engine) (issueDeps []*Dependen
// sort by repo id then created date, with the issues of the same repo at the beginning of the list
OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(issue.RepoID, 10) + " THEN 0 ELSE issue.repo_id END, issue.created_unix DESC").
Find(&issueDeps)
for _, depInfo := range issueDeps {
depInfo.Issue.Repo = &depInfo.Repository
}
return issueDeps, err
}
// Get Blocking Dependencies, aka all issues this issue blocks.
func (issue *Issue) getBlockingDependencies(e db.Engine) (issueDeps []*DependencyInfo, err error) {
return issueDeps, e.
err = e.
Table("issue").
Join("INNER", "repository", "repository.id = issue.repo_id").
Join("INNER", "issue_dependency", "issue_dependency.issue_id = issue.id").
@ -1948,6 +1954,12 @@ func (issue *Issue) getBlockingDependencies(e db.Engine) (issueDeps []*Dependenc
// sort by repo id then created date, with the issues of the same repo at the beginning of the list
OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(issue.RepoID, 10) + " THEN 0 ELSE issue.repo_id END, issue.created_unix DESC").
Find(&issueDeps)
for _, depInfo := range issueDeps {
depInfo.Issue.Repo = &depInfo.Repository
}
return issueDeps, err
}
// BlockedByDependencies finds all Dependencies an issue is blocked by

Loading…
Cancel
Save