cargo-bazel: Corrected sparse registry splicing code (#2325)

This is a fix for supporting sparse-registries (private).

### Issue:

When we tried to use crate_universe together with an internal sparse
registry (Artifactory) we ran into an issue. `cargo-bazel splice` was
not correctly detecting sparse registries as "sparse", even though the
URLs correctly started with the "sparse+https://" prefix in the
Cargo.lock file. Instead it re-interpreted them as registries with a git
index.

The root cause of this is that`cargo_lock::Lockfile` automatically
removes the prefix `sparse+` from the URL and the only way to determine
that a registry is sparse is to check the `kind`. The code previously
assumed it could check for sparse registries by checking if the url
starts with "sparse+https://".

### Problem solution:

This pull requests adapts the code so it uses the lockfile "SourceKind"
instead of the URL to check if a registry is sparse or not.
1 file changed
tree: 63f69150616ba6e1769a136dd8831b57b318b3fd
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. bindgen/
  5. cargo/
  6. crate_universe/
  7. docs/
  8. examples/
  9. ffi/
  10. nix/
  11. proto/
  12. rust/
  13. test/
  14. tools/
  15. util/
  16. wasm_bindgen/
  17. .bazelignore
  18. .bazelrc
  19. .bazelversion
  20. .clang-format
  21. .envrc
  22. .gitattributes
  23. .gitignore
  24. .prettierrc.toml
  25. .rustfmt.toml
  26. ARCHITECTURE.md
  27. AUTHORS
  28. BUILD.bazel
  29. CODEOWNERS
  30. COMPATIBILITY.md
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. LICENSE.txt
  34. MODULE.bazel
  35. README.md
  36. version.bzl
  37. WORKSPACE.bazel
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.