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

Provide path feature with git resource #10151

Closed
yanganto opened this issue Dec 3, 2021 · 3 comments
Closed

Provide path feature with git resource #10151

yanganto opened this issue Dec 3, 2021 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@yanganto
Copy link

yanganto commented Dec 3, 2021

Problem

We want to use a customized git dependency of a crate in a repository, which have more than one Rust crates and the workspace in not in the root of repository.

Following is a real example from WasmEdge

.
├── bindings
│   └── rust
│       ├── Cargo.toml
│       ├── wasmedge-sdk
│       │   └── Cargo.toml
│       └── wasmedge-sys
│           └── Cargo.toml

166 directories, 717 files

If we can use git and path at the same time, everything will be straight forward for developers.
wasmedge-sys = { git = "wasmedge_git_url", path = "/bindings/rust/wasmedge-sys"}

You can check out the following closed issue, people still there and request this feature.
#1462

Proposed Solution

We need to modify the following structure, and allow using path with git, also the path will be transformed to absolute path before using, such that we can make sure the path will not go out of the resource.

src/cargo/core/source/source_id.rs

  #[derive(Eq, Clone, Debug)]
  struct SourceIdInner {
      /// The source URL.
      url: Url,
      /// The canonical version of the above url
      canonical_url: CanonicalUrl,
      /// The source kind.
      kind: SourceKind,
      /// For example, the exact Git revision of the specified branch for a Git Source.
      precise: Option<String>,
      /// Name of the registry source for alternative registries
      /// WARNING: this is not always set for alt-registries when the name is
      /// not known.
      name: Option<String>,
      /// The portion of resource
+     /// For example, the folder for a Git source
+     portion: Option<String>,
  }

src/cargo/sources/config.rs

  struct SourceConfigDef {
      /// Indicates this source should be replaced with another of the given name.
      replace_with: OptValue<String>,
      /// A directory source.
      directory: Option<ConfigRelativePath>,
      /// A registry source. Value is a URL.
      registry: OptValue<String>,
      /// A local registry source.
      local_registry: Option<ConfigRelativePath>,
      /// A git source. Value is a URL.
      git: OptValue<String>,
      /// The git branch.
      branch: OptValue<String>,
      /// The git tag.
      tag: OptValue<String>,
      /// The git revision.
      rev: OptValue<String>,
+     /// The porton of the Source,
+     /// for example the folder of git resoutce
+     portion: Option<String>,
  }

Notes

No response

@yanganto yanganto added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Dec 3, 2021
@ehuss
Copy link
Contributor

ehuss commented Dec 3, 2021

Can you say more about why you would like to specify the path within the git repository? Cargo already searches for the package by name, so unless you have two packages with the exact same name, this should not be necessary.

@yanganto
Copy link
Author

yanganto commented Dec 7, 2021

Thanks ehuss. It works.

@yanganto yanganto closed this as completed Dec 7, 2021
@zapkub
Copy link

zapkub commented Jan 21, 2022

@ehuss what about the repository contain more than two packages with the same name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

3 participants