Simplify and document logic around source/syncer types + parsing functionality
Created by: varungandhi-src
Pasting one of @mrnugget's comments from Slack, in the context of confusion around the purpose behind having multiple interfaces with the same name packagesSource as well as similar types npmPackagesSyncer and npmPackagesSource:
The Source is used as a “source for repos”, to get the list of repositories that repo-updater should insert into the database. The Syncer is the fake git-thing that “clones” the package (downloads it). One is domain of repo-updater, the other is domain of gitserver.
I think the only duplication is the 3 methods for parsing names etc. right? I agree it’s confusing. Especially since the vcsPackagesSyncer, which should wrap npmPackagesSyncer (and others), calls these code-host-specific syncers source and defines another interface called packagesSource, even though it’s a
*Syncerthat goes into it. Probably the best idea at this point is to extract the Parse* functions from each source and (!) syncer and make them available as top-level functions in specific packages, i.e. npm.ParsePackageFromRepoName and gomodule.ParsePackageFromRepoName and then have a top-level function somewhere like ParsePackageFromRepoName(schema string, repoName api.RepoName) that then calls the specific implementation. That would reduce the amount of code and duplication immensly, I think.