Open 0xdapper opened 2 years ago
Semi-related: https://github.com/rust-lang/cargo/issues/10667
Source replacement for git URL doesn't support rev and branch.
Bumping this up, this is a blocker for private project development where forks are not an option. Patching a project to override a crate dependency with a different branch of the same repo would be the way to go but is impossible right now because of this URL check.
A solution would be to compare the whole package specification (including any tag, branch, commit clause) and block only if every field is the same.
I could start work on a PR for it if this solution makes sense and the interest is there.
I definitely agree that it should be supported in cargo properly, but just to mention a workaround in case it's useful to anyone: it's possible to trick cargo into thinking that it's a different repo by using a double slash in the URL, like this:
[patch.'https://github.com/owner/repo']
baz = { git = 'https://github.com/owner//repo', branch = 'my-branch' }
Cloning https://github.com/owner//repo
is the same as cloning https://github.com/owner/repo
, so it works.
@dimonomid I have tried this on Windows and I would like to report that it did not work. Maybe this is a linux-only workaround?
I'm not a Windows expert and don't have it around to try it right now, but I didn't expect that it wouldn't work. Could you share what is the error message?
@dimonomid I have tried this on Windows and I would like to report that it did not work. Maybe this is a linux-only workaround?
That's worked for me on windows, also with ssh paths. Corrected workaround, with specifying ssh/https port in patching path:
[patch.'https://github.com/owner/repo']
baz = { git = 'https://github.com:443/owner/repo', branch = 'my-branch' }
Problem
Currently if I wanted to override and patch dependency across workspace of a dependency
https://github.com/owner/repo
to branchb
this does not workbecause of the input validation here https://github.com/rust-lang/cargo/blob/13662250abdd813755263e0de5623bd314a443db/src/cargo/core/registry.rs#L363-L371
Proposed Solution
Remove the validation or make an exception when the source is a git url?
Notes
No response