mirror of
https://github.com/semver/semver.git
synced 2026-07-10 19:50:47 -05:00
[GH-ISSUE #564] Mnemotechnic : remember ^ versus ~ #4655
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cyrilchapon on GitHub (Apr 28, 2020).
Original GitHub issue: https://github.com/semver/semver/issues/564
Hey !
While I strongly understand
~versus^behavior; I always struggle at remembering which one does what I think it does.Roughly, I always re-read the doc; find the information, and tell myself "Ok, caret equals patch; tild equals minor + patch", and always forget it.
Does anyone knows some Mnemotechnic to learn it for good a single time ? 😄
@klehelley commented on GitHub (Apr 28, 2020):
This repository is about the Semantic Versioning specification, that does not use nor define the
~and^prefixes. Maybe you meant to post your question at https://github.com/npm/cli or https://github.com/npm/node-semver?@cyrilchapon commented on GitHub (Apr 28, 2020):
I'm using Node.js but that's not really a Nodejs specific question (composer, https://devhints.io/semver).
Though, I was sure the semver ranges was defined in the spec; and I'm very surprised to discover it's not the case !
@cyrilchapon commented on GitHub (Apr 28, 2020):
Well; additional question. What spec / standard defines "semver ranges" ? Is that a commonly-used format without being backed by a spec ?
@ljharb commented on GitHub (Apr 28, 2020):
The caret points up, because it means “this one, up to the next major”. The tilde looks like a hand waggling in place, meaning “kind of like this one, the same minor”.
npm defined ranges for itself with https://npmjs.com/semver, whose implementation is effectively the spec.
@Seldaek commented on GitHub (Apr 29, 2020):
Composer implemented mostly-node-compatible range constraints to help with "mental" interoperability as most PHP devs using Composer also use npm to some extent. But indeed the semver spec defines none of this. This spec is only describing how to choose a version number when publishing a new release.
The bottom line though IMO is that if a given dependency strictly follows semver, you should only ever use
^.~seems to be confusing people and I would thus not recommend using it.1.2.*is usually clearer if you just want patches within one minor version.