Skip to content

fix(package): detect dirtiness for symlinks to submodule #15416

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

Merged
merged 3 commits into from
Apr 10, 2025

Conversation

weihanglo
Copy link
Member

What does this PR try to resolve?

If a there is a symlink into a git repository/submodule,
when checking its git status with the wrong outer repo,
we'll get an NotFound error,
as the object doesn't belong to the outer repository.
This kind of error blocked the entire cargo package operation.

This fix additionally discovers the nearest Git repository,
and then checks status with that,
assuming the repo is the parent of the source file of the symlink.
This is a best effort solution, so if the check fails we ignore.

How should we test and review this PR?

If we don't want the complication,
we could drop the last commit, ignore the error, and forget about handling submodules

fixes #15384
fixes #15413

Dirtiness check for symlinks is mostly informational.
And changes in submodule would fail git-status as well (see rust-lang#15384).
To avoid adding complicated logic to handle that,
for now we ignore the status check failure.
@rustbot
Copy link
Collaborator

rustbot commented Apr 10, 2025

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-git Area: anything dealing with git Command-package S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 10, 2025
@epage
Copy link
Contributor

epage commented Apr 10, 2025

Thanks! Looks like its mostly nits, so let me know how much you see worth changing.

If a there is a symlink into a git repository/submodule,
when checking its git status with the wrong outer repo,
we'll get an NotFound error,
as the object doesn't belong to the outer repository.
This kind of error blocked the entire `cargo package` operation.

This fix additionally discovers the nearest Git repository,
and then checks status with that,
assuming the repo is the parent of the source file of the symlink.
This is a best effort solution, so if the check fails we ignore.
@epage epage enabled auto-merge April 10, 2025 17:02
@epage epage added this pull request to the merge queue Apr 10, 2025
Merged via the queue into rust-lang:master with commit f2c4849 Apr 10, 2025
23 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 12, 2025
Update cargo

12 commits in 0e93c5bf6a1d5ee7bc2af63d1afb16cd28793601..864f74d4eadcaea3eeda37a2e7f4d34de233d51e
2025-04-05 00:00:24 +0000 to 2025-04-11 20:37:27 +0000
- chore: Bump build-rs version (rust-lang/cargo#15421)
- fix(build): Correct name of CARGO_CFG_FEATURE (rust-lang/cargo#15420)
- Revert "fix(package): detect dirtiness for symlinks to submodule" (rust-lang/cargo#15419)
- Improved error message when build-dir template var is invalid (rust-lang/cargo#15418)
- Added validation for unmatched brackets in build-dir template (rust-lang/cargo#15414)
- fix(package): detect dirtiness for symlinks to submodule  (rust-lang/cargo#15416)
- chore(deps): bump crossbeam-channel from 0.5.14 to 0.5.15 (rust-lang/cargo#15415)
- docs(metadata): Added build_directory to cargo metadata documentation (rust-lang/cargo#15410)
- Added symlink resolution for `workspace-path-hash` (rust-lang/cargo#15400)
- feat: print target and package names formatted as file hyperlinks (rust-lang/cargo#15405)
- docs(ref): Use better example value in `CARGO_CFG_TARGET_ABI` (rust-lang/cargo#15404)
- chore: Bump cargo-util-schemas to 0.8.2 (rust-lang/cargo#15403)

r? ghost
@rustbot rustbot added this to the 1.88.0 milestone Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-git Area: anything dealing with git Command-package S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
3 participants