Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::sources::source::SourceMap;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{CanonicalUrl, GlobalContext};
use annotate_snippets::{Group, Level};
use anyhow::{Context as _, bail};
use tracing::{debug, trace};
use url::Url;
Expand Down Expand Up @@ -387,16 +388,20 @@ impl<'gctx> PackageRegistry<'gctx> {
unused_fields.push("`default-features`")
}
if !unused_fields.is_empty() {
let mut shell = self.source_config.gctx().shell();
shell.warn(format!(
"unused field in patch for `{}`: {}",
dep.package_name(),
unused_fields.join(", ")
))?;
shell.note(format!(
"configure {} in the `dependencies` entry",
unused_fields.join(", ")
))?;
self.source_config.gctx().shell().print_report(
&[
Group::with_title(Level::WARNING.secondary_title(format!(
"unused field in patch for `{}`: {}",
dep.package_name(),
unused_fields.join(", ")
))),
Group::with_title(Level::NOTE.secondary_title(format!(
"configure {} in the `dependencies` entry",
unused_fields.join(", ")
))),
],
false,
)?;
}

// Go straight to the source for resolving `dep`. Load it as we
Expand Down
33 changes: 20 additions & 13 deletions src/cargo/ops/cargo_package/vcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::core::{Package, Workspace};
use crate::ops::PackageOpts;
use crate::sources::PathEntry;
use crate::{CargoResult, GlobalContext};
use annotate_snippets::{Group, Level};
use anyhow::Context;
use cargo_util::paths;
use gix::bstr::ByteSlice;
Expand Down Expand Up @@ -158,20 +159,26 @@ fn warn_symlink_checked_out_as_plain_text_file(
}

if src_files.iter().any(|f| f.maybe_plain_text_symlink()) {
let mut shell = gctx.shell();
shell.warn(format_args!(
"found symbolic links that may be checked out as regular files for git repo at `{}/`\n\
This might cause the `.crate` file to include incorrect or incomplete files",
repo.workdir().unwrap().display(),
))?;
let extra_note = if cfg!(windows) {
"\nAnd on Windows, enable the Developer Mode to support symlinks"
} else {
""
let msg = format!(
"found symbolic links that may be checked out as regular files for git repo at `{}/`",
repo.workdir().unwrap().display()
);
let mut notes = vec![
Group::with_title(Level::WARNING.secondary_title(msg)),
Group::with_title(Level::NOTE.secondary_title(
"this might cause the `.crate` file to include incorrect or incomplete files",
)),
Group::with_title(
Level::HELP
.secondary_title("to avoid this, set the Git config `core.symlinks` to `true`"),
),
];
if cfg!(windows) {
notes.push(Group::with_title(Level::HELP.secondary_title(
"on Windows, enable the Developer Mode to support symlinks",
)));
};
shell.note(format_args!(
"to avoid this, set the Git config `core.symlinks` to `true`{extra_note}",
))?;
gctx.shell().print_report(&notes, false)?;
}

Ok(())
Expand Down
16 changes: 12 additions & 4 deletions src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ use std::io::Write;
use std::path::{Path, PathBuf};
use std::task::{Poll, ready};

use annotate_snippets::{Group, Level};
use anyhow::Context as _;
use cargo_util::paths::{self, exclude_from_backups_and_indexing};
use flate2::read::GzDecoder;
Expand Down Expand Up @@ -832,10 +833,17 @@ impl<'gctx> Source for RegistrySource<'gctx> {
.expect("--precise <yanked-version> in use");
if self.selected_precise_yanked.insert((name, version.clone())) {
let mut shell = self.gctx.shell();
shell.warn(format_args!(
"selected package `{name}@{version}` was yanked by the author"
))?;
shell.note("if possible, try a compatible non-yanked version")?;
shell.print_report(
&[
Group::with_title(Level::WARNING.secondary_title(format!(
"selected package `{name}@{version}` was yanked by the author"
))),
Group::with_title(Level::NOTE.secondary_title(
"if possible, try a compatible non-yanked version",
)),
],
false,
)?;
}
}
if called {
Expand Down
19 changes: 12 additions & 7 deletions src/cargo/util/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ use crate::util::network::http::configure_http_handle;
use crate::util::network::http::http_handle;
use crate::util::{CanonicalUrl, closest_msg, internal};
use crate::util::{Filesystem, IntoUrl, IntoUrlWithBase, Rustc};
use annotate_snippets::{Group, Level};
use anyhow::{Context as _, anyhow, bail, format_err};
use cargo_credential::Secret;
use cargo_util::paths;
Expand Down Expand Up @@ -1582,13 +1583,17 @@ impl GlobalContext {
))?;
}
} else {
self.shell().warn(format!(
"`{}` is deprecated in favor of `{filename_without_extension}.toml`",
possible.display(),
))?;
self.shell().note(
format!("if you need to support cargo 1.38 or earlier, you can symlink `{filename_without_extension}` to `{filename_without_extension}.toml`"),
)?;
self.shell().print_report(&[
Group::with_title(
Level::WARNING.secondary_title(format!(
"`{}` is deprecated in favor of `{filename_without_extension}.toml`",
possible.display(),
)
)),
Group::with_title(Level::NOTE.secondary_title(
format!("if you need to support cargo 1.38 or earlier, you can symlink `{filename_without_extension}` to `{filename_without_extension}.toml`")
))
], false)?;
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7450,8 +7450,8 @@ fn git_core_symlinks_false() {
p.cargo("package --allow-dirty")
.with_stderr_data(str![[r#"
[WARNING] found symbolic links that may be checked out as regular files for git repo at `[ROOT]/foo/`
This might cause the `.crate` file to include incorrect or incomplete files
[NOTE] to avoid this, set the Git config `core.symlinks` to `true`
[NOTE] this might cause the `.crate` file to include incorrect or incomplete files
[HELP] to avoid this, set the Git config `core.symlinks` to `true`
...
[PACKAGING] bar v0.0.0 ([ROOT]/foo)
[PACKAGED] 7 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
Expand Down