killercup / cargo-edit

A utility for managing cargo dependencies from the command line.
http://killercup.github.io/cargo-edit/
MIT License
3.07k stars 148 forks source link

`cargo add`: include only MAJOR.MINOR #126

Closed ordian closed 2 years ago

ordian commented 7 years ago

Add an option (or enable by default) to add a dependency with version = MAJOR.MINOR, not MAJOR.MINOR.PATCH.

ordian commented 2 years ago

Getting back to the original topic, I believe something like #436 would be useful as it gives the user flexibility to choose the default style. And #217 could make it automatic by default.

epage commented 2 years ago

@ordian thoughts on some of the reasons given earlier against #436, like mine?

ordian commented 2 years ago

I do not think this should be in a persistent configuration, its too situational

My assumption that people want consistent scheme for versioning, some even want =x.y.x: https://github.com/killercup/cargo-edit/pull/436#issuecomment-1011293307. It's possible to specify a concrete version with format already with cargo add cc@=1.0.22. But I agree handling 0.x.y corner cases might be tricky.

But I think it's possible to implement this feature later as an experimental in cargo if there's a consensus people actually want this.

epage commented 2 years ago

some even want =x.y.x: #436 (comment).

For specifying the operator in cargo-add, we had --upgrade which I removed, see internals for my motivation). Some of the reasoning applies to making the operator configurable as well.

Also, I see #436 modifies cargo-upgrade though I haven't dug into that PR or the code. Does cargo-upgrade reserve the existing operator? If not, that seems like a bug to me and we should use the cargo-set-version code to preserve it.

ordian commented 2 years ago

Does cargo-upgrade reserve the existing operator? If not, that seems like a bug to me and we should use the cargo-set-version code to preserve it.

No, we don't preserve the operator, but it's not clear what's the intended behavior, for example

a = "=1.2.3"
b = "> 1.0, < 3.0"
c = "3.0.0-alpha"
d = "0.9"

what should running cargo upgrade produce? But that's a separate topic for discussion.