summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-11-18 08:18:12 +0000
committerGitHub <noreply@github.com>2021-11-18 03:18:12 -0500
commit878c2ce6e63e20e147c1e306a834bde15b06cb88 (patch)
tree8a3d448578e75c95a7980ac24fa9974500dd826f /models
parent1f1ae571393440c0260a00f98b4ebcfd162c7970 (diff)
downloadgitea-878c2ce6e63e20e147c1e306a834bde15b06cb88.tar.gz
gitea-878c2ce6e63e20e147c1e306a834bde15b06cb88.zip
Prevent NPE due to missing repo in regression in #17551 (#17697)
Diffstat (limited to 'models')
-rw-r--r--models/issue.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go
index 983fb7aa8d..288163707a 100644
--- a/models/issue.go
+++ b/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