librariesio / libraries.io

:books: The Open Source Discovery Service
https://libraries.io
GNU Affero General Public License v3.0
1.1k stars 206 forks source link

Move Repository create_or_update Logic to a Domain Class #3345

Closed mikeyoung85 closed 2 months ago

mikeyoung85 commented 3 months ago

I wanted to move this logic out of the Repository and RepositoryHost classes. It felt complicated enough where it warranted being separated so it could be easier to test. There is also some dependency in between Repository and RepositoryHost that made it hard to follow the code path and I thought separating this out would be helpful in reducing that complexity. The interface to this logic still comes through the same methods and parameters, but a further refactor could be changing how callers to these functions are interacting with this create or update logic. There were no specs checking this section of the code so I have added some based on how I read the code but if it looks incorrect please call that out. Let me know if you think this refactor is worth the possible troubles that come with touching this portion of the code base.