-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cargo package
VCS dirty check corner cases
#14967
Comments
Options
I re-implement this check in cargo-release so I catch it before the release process, not just publish. It check if the workspace is clean (instead it should check if the whole repo is clean). I implemented it this way because (1) its simpler and (2) people can hook into cargo-release and do their own thing so I can't exhaustively know all the files. If we check the whole repo, potential broken workflows
|
BTW the doc says this: cargo/src/doc/src/commands/cargo-package.md Lines 60 to 61 in 9c17646
and this:
So it seems to look at the repository as a whole when it was designed, but #2781 made it check only files from #2063 has some discussion around this. Haven't read through all of them. |
Looking through that, it seems there was a larger problem being dealt with and there was some discussion of details but not too much on this point (except one person not wanting cargo to be opinionated). |
### What does this PR try to resolve? This adds a special case for `package.{readme,license-file}` to Git VCS status check. If they were specified with paths outside the current package root, but still under git workdir, Cargo checks git status of those files to determine if they were dirty. We don't need to take care of other fields with path values because * `PathSource` only list files under the package root. Things like `target.path` works for `cargo build`, but won't be included in `.crate` file from `cargo publish`. * The only exceptions are `package.readme`/`package.license-file`. Cargo would copy files over if they are outside package root. ### How should we test and review this PR? While this doesn't fix ever case listed in #14967, it at least fixes one of them.
Regarding potential solutions to fixing workspace inheritance, there are a couple of ideas
|
### What does this PR try to resolve? This adds a special case for checking source files are symlinks and have been modified when under a VCS control This is required because those paths may link to a file outside the current package root, but still under the git workdir, affecting the final packaged `.crate` file. ### How should we test and review this PR? Pretty similar to #14966, as a part of #14967. This may have potential performance issue. If a package contains thousands of symlinks, Cargo will fire `git status` for each of them. Not sure if we want to do anything proactively now. The introduction of the `PathEntry` struct gives us more room for storing file metadata to satisfiy use cases in the future. For instances, * Knowing a source file is a symlink and resolving it when packaging on Windows * #5664 * #14965 * Knowing more about a file's metadata (e.g. permission bits from Git) * #4413 * #8006 * Provide richer information for `cargo package --list`, for example JSON output mode * #11666 * #13331 * #13953
Problem
During the investigation of #14955 and #14962, we found more corner cases that
cargo package
doesn't consider dirty. You don't even need to pass--allow-dirty
flag to explicitly allow it..cargo_vcs_info.json
shows no dirty at all. However, the actual packaged.crate
file contains dirty files.Let's consider this virtual workspace:
There are at least three corner cases:
PathSource::list_files
list symlink as ordinary file. When doing dirty check, the naive path prefix check is not able to find the symlink source file dirty.package.license-file
andpackage.readme
— they are copied duringcargo package
.PathSource::list_files
doesn't even report them because they are not under the directory of the package.workspace.package.edition
to2021
would actually make foo's Cargo.toml dirty, but the current dirty status check doesn't capture that.Steps
See #14966
Possible Solution(s)
No response
Notes
No response
Version
9c17646
The text was updated successfully, but these errors were encountered: