add repo to teams with access to all repositories when changing repo owner

This commit is contained in:
Nicolas Gourdon 2019-05-08 16:16:12 +02:00
parent f6983856de
commit 04965880f6

View file

@ -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.