From 14bd120cdc5dab2a7c854346b7f4bf69507627ae Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Wed, 19 Feb 2020 00:02:50 -0300 Subject: [PATCH] Reading pull attachments should depend on read UnitTypePullRequests (#10346) (#10354) Co-authored-by: zeripath --- models/attachment.go | 6 +++++- models/attachment_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index 6cfa6cb64..81f2e15da 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -79,7 +79,11 @@ func (a *Attachment) LinkedRepository() (*Repository, UnitType, error) { return nil, UnitTypeIssues, err } repo, err := GetRepositoryByID(iss.RepoID) - return repo, UnitTypeIssues, err + unitType := UnitTypeIssues + if iss.IsPull { + unitType = UnitTypePullRequests + } + return repo, unitType, err } else if a.ReleaseID != 0 { rel, err := GetReleaseByID(a.ReleaseID) if err != nil { diff --git a/models/attachment_test.go b/models/attachment_test.go index ddb6abad3..7d681e051 100644 --- a/models/attachment_test.go +++ b/models/attachment_test.go @@ -138,7 +138,7 @@ func TestLinkedRepository(t *testing.T) { expectedUnitType UnitType }{ {"LinkedIssue", 1, &Repository{ID: 1}, UnitTypeIssues}, - {"LinkedComment", 3, &Repository{ID: 1}, UnitTypeIssues}, + {"LinkedComment", 3, &Repository{ID: 1}, UnitTypePullRequests}, {"LinkedRelease", 9, &Repository{ID: 1}, UnitTypeReleases}, {"Notlinked", 10, nil, -1}, }