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() { if newOwner.IsOrganization() {
t, err := newOwner.getOwnerTeam(sess) if err := newOwner.GetTeams(); err != nil {
if err != nil { return fmt.Errorf("GetTeams: %v", err)
return fmt.Errorf("getOwnerTeam: %v", err) }
} else if err = t.addRepository(sess, repo); err != nil { for _, t := range newOwner.Teams {
return fmt.Errorf("add to owner team: %v", err) if t.IncludesAllRepositories {
if err := t.addRepository(sess, repo); err != nil {
return fmt.Errorf("addRepository: %v", err)
}
}
} }
} else { } else {
// Organization called this in addRepository method. // Organization called this in addRepository method.