Use strip_path_canonical for getting the relative path

This resolve an issue where the package path contains a symlink that's resolved by git
This commit is contained in:
Arlo Siemsen 2024-04-03 12:59:49 -05:00
parent 45c390a2a5
commit 312e2aab7f
2 changed files with 4 additions and 3 deletions

View File

@ -533,8 +533,9 @@ fn check_repo_state(
if let Some(workdir) = repo.workdir() {
debug!("found a git repo at {:?}", workdir);
let path = p.manifest_path();
let path = path.strip_prefix(workdir).unwrap_or(path);
if let Ok(status) = repo.status_file(path) {
let path =
paths::strip_prefix_canonical(path, workdir).unwrap_or_else(|_| path.to_path_buf());
if let Ok(status) = repo.status_file(&path) {
if (status & git2::Status::IGNORED).is_empty() {
debug!(
"found (git) Cargo.toml at {:?} in workdir {:?}",

View File

@ -3538,7 +3538,7 @@ fn symlink_manifest_path() {
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[..]
[PACKAGED] 6 files[..]
",
)
.run()