codeintel: Fix repository inference for NPM packages.
Created by: varungandhi-src
Later code in gitserver.RepoInfo uses the repo name to infer a path where the repo contents are cloned. NPM package have their contents cloned under an npm/ subdirectory (similar to github.com/) under .sourcegraph/repos. However, this code was just passing in the package name instead of using the proper repo name which has an npm/ prefix, and removes an @ from the scope (if a scope is present).
Questions:
- Should we add an integration test or broadly some larger test here? The failure mode seems particularly unfortunate, what ends up happening is that the call to
RepoInfo
returns entries withIsCloned
set to false, because it ends up looking at the wrong directory (under~/.sourcegraph/repos/<package>
rather than under~/.sourcegraph/repos/npm/<package>
. So no jobs are scheduled underQueueIndexesForPackage
.🤦 - Does this same problem apply to Maven packages? I've left a TODO in that spot in the code.
- I'm currently dropping an error for the situation where we accidentally put the name in an incorrect format in the database (so parsing the package will fail). Should that error be bubbled up instead?
Test plan
- I've add some tests for the main function that was fixed.