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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ supported. Git/path dependencies will be ignored.

All packages in the workspace will be upgraded if the `--workspace` flag is supplied.
The `--workspace` flag may be supplied in the presence of a virtual manifest.
Running in workspace root automatically implies `--workspace`

If the '--to-lockfile' flag is supplied, all dependencies will be upgraded to the currently locked
version as recorded in the Cargo.lock file. This flag requires that the Cargo.lock file is
Expand Down
3 changes: 2 additions & 1 deletion src/bin/set-version/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ fn process(args: Args) -> Result<()> {
if all {
deprecated_message("The flag `--all` has been deprecated in favor of `--workspace`")?;
}
let all = workspace || all;
let all = workspace || all || LocalManifest::find(&None)?.is_virtual();

let manifests = if all {
Manifests::get_all(&manifest_path)
} else if let Some(ref pkgid) = pkgid {
Expand Down
4 changes: 3 additions & 1 deletion src/bin/upgrade/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct Args {
all: bool,

/// Upgrade all packages in the workspace.
/// Implied by default when running in a directory with virtual manifest.
#[structopt(long = "workspace", conflicts_with = "all", conflicts_with = "pkgid")]
workspace: bool,

Expand Down Expand Up @@ -468,7 +469,8 @@ fn process(args: Args) -> Result<()> {
deprecated_message("The flag `--all` has been deprecated in favor of `--workspace`")?;
}

let all = workspace || all;
// Running in workspace root automatically implies `--workspace`
let all = workspace || all || LocalManifest::find(&None)?.is_virtual();

if !args.offline && !to_lockfile && std::env::var("CARGO_IS_TEST").is_err() {
let url = registry_url(&find(&manifest_path)?, None)?;
Expand Down
7 changes: 6 additions & 1 deletion src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,15 @@ impl LocalManifest {
Ok(LocalManifest { manifest, path })
}

/// Check if local manifest is virtual, i. e. corresponds to workspace root
pub fn is_virtual(&self) -> bool {
!self.data["workspace"].is_none()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existence of a workspace table does not make it virtual. To be virtual, it also needs to not have a package.

Check out https://github.com/crate-ci/clap-cargo/blob/master/src/workspace.rs#L29 for a good approximation of what cargo does.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll fix it a bit later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could just port the project over to clap-cargo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clap-cargo look like an amazing project! I'm willing to help with the porting.

}

/// Write changes back to the file
pub fn write(&self) -> Result<()> {
if self.manifest.data["package"].is_none() && self.manifest.data["project"].is_none() {
if !self.manifest.data["workspace"].is_none() {
if self.is_virtual() {
return Err(ErrorKind::UnexpectedRootManifest.into());
} else {
return Err(ErrorKind::InvalidManifest.into());
Expand Down