bazelbuild / bazelbuild/rules_rust

`cargo_universe`: Incorrect handling of `git` dependencies with `branch = "main"`

Open
#2,502 2 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

I have a project with a cargo dependency of the form

`a = { git = "...", branch = "main"}`
(the branch parameter is necessary because `rules_rust` assumes that the default branch of the repo is called main).
`Cargo.lock` contains
```
[[package]]
name = "a"
version = "0.2.0"
source = "git+...?branch=main#2da00986c01e979838b4a4c4a82dcc74a8df310a"
```

which I assume pins this package at that given commit, until the lockfile is updated again.
However, `Cargo.bazel.lock` only contains
```json
"Git": {
"remote": "https://github.com/github/codeql.git",
"commitish": {
"Branch": "main"
},
```
which then in turn creates a `new_git_repository` rule that clones the `main` branch directly, without any commit pinning. That breaks build hermeticity, and potentially builds different code than cargo would.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.