Skip to content

Comments

Fix re-init#204

Merged
pksunkara merged 1 commit intopksunkara:masterfrom
abelmarnk:fix-re-init
Dec 3, 2025
Merged

Fix re-init#204
pksunkara merged 1 commit intopksunkara:masterfrom
abelmarnk:fix-re-init

Conversation

@abelmarnk
Copy link
Contributor

Each time the init command is run on an already existing workspace the workspace(explicit as "") is added to the Cargo.toml each time, causing errors, this change makes a re-init to be a no-op.
Note: In the case where new packages were added to the workspace since it was initially initialized, if the new packages reflect in the Cargo.toml then the only thing that happens is what is described above, in the case where it doesn't, the init command fails with a cargo-metadata error, so except for the change described above the init command stays the same.

@pksunkara
Copy link
Owner

I am willing to accept this change, but can you please add appropriate tests? Thanks.

@abelmarnk
Copy link
Contributor Author

I've added more tests, i also renamed the tests for clarity since there are more cases to consider.

@pksunkara
Copy link
Owner

Looks good, just minor issues:

  1. Fix formatting using cargo fmt
  2. The error of the failing test cannot use snapshot. You can do it similarly to how I have done in a few other places. For ex:
    assert!(err.contains("error: the workspace already contains a package with this name"));

@abelmarnk
Copy link
Contributor Author

Thanks for the feedback, I've made the changes.

@pksunkara
Copy link
Owner

Thanks for the high-quality PR. Really appreciate it. 🫰

@pksunkara pksunkara merged commit 6183143 into pksunkara:master Dec 3, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants