Skip to content

Commit 312e2aa

Browse files
committed
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
1 parent 45c390a commit 312e2aa

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cargo/ops/cargo_package.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ fn check_repo_state(
533533
if let Some(workdir) = repo.workdir() {
534534
debug!("found a git repo at {:?}", workdir);
535535
let path = p.manifest_path();
536-
let path = path.strip_prefix(workdir).unwrap_or(path);
537-
if let Ok(status) = repo.status_file(path) {
536+
let path =
537+
paths::strip_prefix_canonical(path, workdir).unwrap_or_else(|_| path.to_path_buf());
538+
if let Ok(status) = repo.status_file(&path) {
538539
if (status & git2::Status::IGNORED).is_empty() {
539540
debug!(
540541
"found (git) Cargo.toml at {:?} in workdir {:?}",

tests/testsuite/package.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3538,7 +3538,7 @@ fn symlink_manifest_path() {
35383538
warning: manifest has no description, license, license-file, documentation, homepage or repository.
35393539
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
35403540
[PACKAGING] foo v1.0.0 ([..]foo-symlink)
3541-
[PACKAGED] 5 files[..]
3541+
[PACKAGED] 6 files[..]
35423542
",
35433543
)
35443544
.run()

0 commit comments

Comments
 (0)