Skip to content

codeintel: Fix repository inference for NPM packages.

Administrator requested to merge vg/fix-repoName-mixup into main

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:

  1. 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 with IsCloned 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 under QueueIndexesForPackage. 🤦
  2. Does this same problem apply to Maven packages? I've left a TODO in that spot in the code.
  3. 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.

Merge request reports

Loading