mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Switch to using gitoxide by default for listing files
This commit is contained in:
parent
09d5e964ad
commit
45c390a2a5
@ -909,8 +909,6 @@ fn parse_git(it: impl Iterator<Item = impl AsRef<str>>) -> CargoResult<Option<Gi
|
|||||||
pub struct GitoxideFeatures {
|
pub struct GitoxideFeatures {
|
||||||
/// All fetches are done with `gitoxide`, which includes git dependencies as well as the crates index.
|
/// All fetches are done with `gitoxide`, which includes git dependencies as well as the crates index.
|
||||||
pub fetch: bool,
|
pub fetch: bool,
|
||||||
/// Listing of files suitable for packaging with Git support.
|
|
||||||
pub list_files: bool,
|
|
||||||
/// Checkout git dependencies using `gitoxide` (submodules are still handled by git2 ATM, and filters
|
/// Checkout git dependencies using `gitoxide` (submodules are still handled by git2 ATM, and filters
|
||||||
/// like linefeed conversions are unsupported).
|
/// like linefeed conversions are unsupported).
|
||||||
pub checkout: bool,
|
pub checkout: bool,
|
||||||
@ -924,7 +922,6 @@ impl GitoxideFeatures {
|
|||||||
fn all() -> Self {
|
fn all() -> Self {
|
||||||
GitoxideFeatures {
|
GitoxideFeatures {
|
||||||
fetch: true,
|
fetch: true,
|
||||||
list_files: true,
|
|
||||||
checkout: true,
|
checkout: true,
|
||||||
internal_use_git2: false,
|
internal_use_git2: false,
|
||||||
}
|
}
|
||||||
@ -935,7 +932,6 @@ impl GitoxideFeatures {
|
|||||||
fn safe() -> Self {
|
fn safe() -> Self {
|
||||||
GitoxideFeatures {
|
GitoxideFeatures {
|
||||||
fetch: true,
|
fetch: true,
|
||||||
list_files: true,
|
|
||||||
checkout: true,
|
checkout: true,
|
||||||
internal_use_git2: false,
|
internal_use_git2: false,
|
||||||
}
|
}
|
||||||
@ -948,7 +944,6 @@ fn parse_gitoxide(
|
|||||||
let mut out = GitoxideFeatures::default();
|
let mut out = GitoxideFeatures::default();
|
||||||
let GitoxideFeatures {
|
let GitoxideFeatures {
|
||||||
fetch,
|
fetch,
|
||||||
list_files,
|
|
||||||
checkout,
|
checkout,
|
||||||
internal_use_git2,
|
internal_use_git2,
|
||||||
} = &mut out;
|
} = &mut out;
|
||||||
@ -957,10 +952,9 @@ fn parse_gitoxide(
|
|||||||
match e.as_ref() {
|
match e.as_ref() {
|
||||||
"fetch" => *fetch = true,
|
"fetch" => *fetch = true,
|
||||||
"checkout" => *checkout = true,
|
"checkout" => *checkout = true,
|
||||||
"list-files" => *list_files = true,
|
|
||||||
"internal-use-git2" => *internal_use_git2 = true,
|
"internal-use-git2" => *internal_use_git2 = true,
|
||||||
_ => {
|
_ => {
|
||||||
bail!("unstable 'gitoxide' only takes `fetch`, `list-files` and 'checkout' as valid input, for shallow fetches see `-Zgit=shallow-index,shallow-deps`")
|
bail!("unstable 'gitoxide' only takes `fetch` and 'checkout' as valid input, for shallow fetches see `-Zgit=shallow-index,shallow-deps`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,13 +143,14 @@ impl<'gctx> PathSource<'gctx> {
|
|||||||
let git_repo = if no_include_option {
|
let git_repo = if no_include_option {
|
||||||
if self
|
if self
|
||||||
.gctx
|
.gctx
|
||||||
.cli_unstable()
|
.get_env("__CARGO_GITOXIDE_DISABLE_LIST_FILES")
|
||||||
.gitoxide
|
.ok()
|
||||||
.map_or(false, |features| features.list_files)
|
.as_deref()
|
||||||
|
== Some("1")
|
||||||
{
|
{
|
||||||
self.discover_gix_repo(root)?.map(Git2OrGixRepository::Gix)
|
|
||||||
} else {
|
|
||||||
self.discover_git_repo(root)?.map(Git2OrGixRepository::Git2)
|
self.discover_git_repo(root)?.map(Git2OrGixRepository::Git2)
|
||||||
|
} else {
|
||||||
|
self.discover_gix_repo(root)?.map(Git2OrGixRepository::Gix)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -3510,3 +3510,36 @@ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and poin
|
|||||||
.with_stderr(&expect_msg)
|
.with_stderr(&expect_msg)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn symlink_manifest_path() {
|
||||||
|
// Test `cargo install --manifest-path` pointing through a symlink.
|
||||||
|
if !symlink_supported() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let p = git::new("foo", |p| {
|
||||||
|
p.file("Cargo.toml", &basic_manifest("foo", "1.0.0"))
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
// Triggers discover_git_and_list_files for detecting changed files.
|
||||||
|
.file("build.rs", "fn main() {}")
|
||||||
|
});
|
||||||
|
#[cfg(unix)]
|
||||||
|
use std::os::unix::fs::symlink;
|
||||||
|
#[cfg(windows)]
|
||||||
|
use std::os::windows::fs::symlink_dir as symlink;
|
||||||
|
|
||||||
|
let foo_symlink = paths::root().join("foo-symlink");
|
||||||
|
t!(symlink(p.root(), &foo_symlink));
|
||||||
|
|
||||||
|
cargo_process("package --no-verify --manifest-path")
|
||||||
|
.arg(foo_symlink.join("Cargo.toml"))
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
warning: manifest has no description, license, license-file, documentation, homepage or repository.
|
||||||
|
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||||
|
[PACKAGING] foo v1.0.0 ([..]foo-symlink)
|
||||||
|
[PACKAGED] 5 files[..]
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user