From 04965880f630c7c15c38f0b09923aa101bf62a24 Mon Sep 17 00:00:00 2001 From: Nicolas Gourdon Date: Wed, 8 May 2019 16:16:12 +0200 Subject: [PATCH] add repo to teams with access to all repositories when changing repo owner --- models/repo.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/models/repo.go b/models/repo.go index d406e69e1c..2db1ed48f9 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1549,11 +1549,15 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error } if newOwner.IsOrganization() { - t, err := newOwner.getOwnerTeam(sess) - if err != nil { - return fmt.Errorf("getOwnerTeam: %v", err) - } else if err = t.addRepository(sess, repo); err != nil { - return fmt.Errorf("add to owner team: %v", err) + if err := newOwner.GetTeams(); err != nil { + return fmt.Errorf("GetTeams: %v", err) + } + for _, t := range newOwner.Teams { + if t.IncludesAllRepositories { + if err := t.addRepository(sess, repo); err != nil { + return fmt.Errorf("addRepository: %v", err) + } + } } } else { // Organization called this in addRepository method.