]> source.dussan.org Git - gitea.git/commitdiff
Reading pull attachments should depend on read UnitTypePullRequests (#10346)
authorzeripath <art27@cantab.net>
Wed, 19 Feb 2020 00:36:19 +0000 (00:36 +0000)
committerGitHub <noreply@github.com>
Wed, 19 Feb 2020 00:36:19 +0000 (21:36 -0300)
* Make pull attachments depend on read UnitTypePullRequests

Fixes #10336

* Fix test

models/attachment.go
models/attachment_test.go

index 6cfa6cb64ec3c194626d8fb6e435474dfd1c645f..81f2e15dad80fe86da965bb1fc32d2d32ac2542e 100644 (file)
@@ -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 {
index ddb6abad3212500a7343adf2bfef6ed25bf0288d..7d681e051902f6eabe3612b98803dc10881d3ad6 100644 (file)
@@ -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},
        }