-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Grab the correct name of RemoteOrganization to use in the query #7430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We were using the naked response from GitHub to exclude `RemoteOrganization` objects and delete the ones where the user don't have permissions anymore. However, we need the organization details instead that comes with the `name` attribute which is the one that we use to create the `RemoteOrganization` object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this could use a test
Instead of returning a list of dictionaries with different structure, we are returning a list of RemoteRepository and RemoteOrganization. Then, we use the same field names (`full_name` and `name`) from the objects we are going to filter by the old values to be removed. This reduces the complexity of choosing the right field for each service from the dictionary previously returned; avoiding picking the wrong field, returning `None` and removing all the Remote* objects for that user.
- `sync_repositories` creates RemoteRepository from API - `sync_organizations` creates RemoteOrganization from API - `sync` removes stale RemoteRepository and RemoteOrganization - do not remove RemoteRepository if linked to a Project - do not remove RemoteRepository where the user still have permissions
@@ -25,3 +25,5 @@ pytest-mock==3.3.0 | |||
# local debugging tools | |||
datadiff==2.0.0 | |||
ipdb==0.13.3 | |||
|
|||
requests-mock==1.8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: now we can remove this dep from .com
We were using the naked response from GitHub to exclude `RemoteOrganization` objects and delete the ones where the user don't have permissions anymore. However, we need the organization details instead that comes with the `name` attribute which is the one that we use to create the `RemoteOrganization` object.
c49478e
to
12d0a52
Compare
This looks good once we fix the conflict. 👍 |
…dthedocs.org into humitos/sync-orgs-github
`name` is not mandatory and some organization does not have it. That's why we were deleting some valid organizations.
…humitos/sync-orgs-github
@stsewd be careful with force-push next time. You deleted a commit that added some tests. |
We were using the naked response from GitHub to excludeRemoteOrganization
objects and delete the ones where the user don't have permissions anymore.However, we need the organization details instead that comes with thename
attribute which is the one that we use to create theRemoteOrganization
object.I refactored this code to always return a list of
RemoteRepository
andRemoteOrganization
from thesync_repositories
andsync_organizations
methods on each service to avoid using the wrong field name, as we were doing.Closes #7381