Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to "clone and patch" #115

Open
epage opened this issue Sep 4, 2024 · 7 comments
Open

Ability to "clone and patch" #115

epage opened this issue Sep 4, 2024 · 7 comments

Comments

@epage
Copy link
Contributor

epage commented Sep 4, 2024

Say I want to edit a dep but I don't yet have it locally. Being able to run cargo override foo --clone and have it choose a good default location (target/tmp/patches/<spec>?) would be a big help. I could then override the output location with cargo override foo --clone --path ... (and the target path must not exist)

Some inspiration for the cloning part:

@epage
Copy link
Contributor Author

epage commented Sep 4, 2024

See also rust-lang/cargo#1545

@eopb
Copy link
Owner

eopb commented Sep 5, 2024

This is great, and I think it's absolutely something we'd like to be able to do. I actually had a conversation with @Eh2406 at Rust Nation about a similar feature, while cargo-override was mostly just an idea.

One question that came up was about where to source the clones of the crates. The thinking was that it may be nice to attempt to git clone using the repository field in the dependencies manifest, only using the registry as a fallback.

The would be to make it easier to upstream changes made to the patch, which I think is something I'd like to encourage.

That being said, cloning this way may not be worth the complexity. Maybe we can implement cloning from the registry first and then consider if it's worth also attempting to clone with git.

@epage
Copy link
Contributor Author

epage commented Sep 5, 2024

Why do you expect cloning from git to be difficult?

btw the issue for Cargo to "clone" from a .crate is rust-lang/cargo#1861.

I wonder if those should be separate operations to opt into.

@eopb
Copy link
Owner

eopb commented Sep 5, 2024

Ah, I didn't read your links in enough detail. Just noticed that https://github.com/ehuss/cargo-clone-crate is already cloning from the repo. I'll take a look at what that project is doing, and give the links you posted a more detailed look 👀

@epage
Copy link
Contributor Author

epage commented Sep 5, 2024

Huh, something missing from https://github.com/ehuss/cargo-clone-crate is to read from .cargo_vcs_info.json to clone to the sha used for the registry package. In 1.81, we populate that also for --allow-dirty publishes. We should probably warn if "dirty": true is set that there are differences between the repo and the registry package.

@eopb
Copy link
Owner

eopb commented Sep 5, 2024

😮, .cargo_vcs_info.json is perfect. I didn't know about that file. The path_in_vcs field could also be very useful for this

@futile
Copy link

futile commented Oct 24, 2024

A super simple first step could be printing something like:

$ cargo override foo --path ../foo
[...] 
The given path does not yet exist. You can clone the upstream repository to this location using:
  git clone <repo-url> <path>

If the given path does not yet exist, but a package name was given. Would allow the user to easily copy & paste the command to check and run it themselves, and not automatically put something somewhere into the filesystem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants