killercup / killercup/cargo-edit
Add support for managing "[patch.crates-io]"
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 166
- PR merge metrics
- No merged PRs in 30d
Description
The proposal is to allow cargo-edit to manage this Cargo feature:
https://rust-lang-nursery.github.io/edition-guide/rust-2018/cargo-and-crates-io/replacing-dependencies-with-patch.html
The command `cargo add-patch frob --path=~/frob` would add a line to a `patch` section in `Cargo.toml`:
```
[patch.crates-io]
frob = { path = "/home/user/frob" }
```
The `cargo rm-patch frob` would remove this line.
Some complexities / open questions:
* The section may have to be created when adding a patch.
* The section should probably be deleted when removing the last line of content.
* The section name contains the repository name (which is usually, but not always, `crates-io`). This could be specified using an extra argument that defaults to the default repository, but the naming of that argument is a bit tricky since you are potentially dealing with two repository names (the original one and the override). We could also in theory try to auto-detect the repository name by searching the dependency graph for the named crate, but (again, in theory) I think it might be possible to find two crates with the same name in the dependency graph from different repositories?
Edit: Made various changes after thinking about it some more.
Contributor guide
Research direction
Start by tracing the existing cargo add and cargo rm command paths and how they modify Cargo.toml. Implement the proposed cargo add-patch and cargo rm-patch behavior, resolving how to create or remove [patch.crates-io] and how an alternate repository should be selected; done means patch entries are added and removed correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100