@@ -191,21 +191,32 @@ def sync(self):
191
191
192
192
- creates a new RemoteRepository/Organization per new repository
193
193
- updates fields for existing RemoteRepository/Organization
194
- - deletes old RemoteRepository/Organization that are not present for this user
194
+ - deletes old RemoteRepository/Organization that are not present
195
+ for this user in the current provider
195
196
"""
196
197
repos = self .sync_repositories ()
197
198
organizations , organization_repos = self .sync_organizations ()
198
199
199
200
# Delete RemoteRepository where the user doesn't have access anymore
200
201
# (skip RemoteRepository tied to a Project on this user)
201
202
repository_full_names = self .get_repository_full_names (repos + organization_repos )
202
- self .user .oauth_repositories .exclude (
203
- Q (full_name__in = repository_full_names ) | Q (project__isnull = False )
204
- ).delete ()
203
+ (
204
+ self .user .oauth_repositories
205
+ .exclude (
206
+ Q (full_name__in = repository_full_names ) | Q (project__isnull = False )
207
+ )
208
+ .filter (account = self .account )
209
+ .delete ()
210
+ )
205
211
206
212
# Delete RemoteOrganization where the user doesn't have access anymore
207
213
organization_names = self .get_organization_names (organizations )
208
- self .user .oauth_organizations .exclude (name__in = organization_names ).delete ()
214
+ (
215
+ self .user .oauth_organizations
216
+ .exclude (name__in = organization_names )
217
+ .filter (account = self .account )
218
+ .delete ()
219
+ )
209
220
210
221
def create_repository (self , fields , privacy = None , organization = None ):
211
222
"""
0 commit comments