【问题标题】:Difference between ^1.0 and ~1.0 version in githubgithub中^1.0和~1.0版本的区别
【发布时间】:2018-04-07 19:22:57
【问题描述】:

谁能解释一下^1.0和~1.0的区别

  "miserenkov/yii2-phone-validator": "^1.0"

   "udokmeci/yii2-phone-validator" : "~1.0"

谢谢

【问题讨论】:

    标签: github version-control version


    【解决方案1】:

    这些就是所谓的“Next Significant Release Operators”。

    ~ 运算符最好通过示例来解释:~1.2 等价于 >=1.2 =1.2.3

    .. 而 ^ 稍微允许一些:

    ^ 运算符的行为非常相似,但它更接近语义版本控制,并且始终允许不间断更新。例如 ^1.2.3 等价于 >=1.2.3

    更新~1.2.3 不会升级到除1.2.x 以外的任何东西,而^1.2.3 可以更新到比1.2.3 更新的任何东西,一直到2.0.0

    在您的情况下,它们的行为应该相同。

    【讨论】:

      【解决方案2】:

      来自文档: https://getcomposer.org/doc/articles/versions.md

      Caret Version Range (^)#
      
      The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates.
      For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility.
      For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.
      
      Tilde Version Range (~)#
      
      The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.
      As you can see it is mostly useful for projects respecting semantic versioning.
      A common usage would be to mark the minimum minor version you depend on, like ~1.2 (which allows anything up to, but not including, 2.0).
      Since in theory there should be no backwards compatibility breaks until 2.0, that works well.
      Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.
      

      【讨论】:

        【解决方案3】:

        在节点 "^1.0" 始终更新到最新版本,"~ 1.0" 将保持当前版本。

        希望这会有所帮助!

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-08-27
          • 1970-01-01
          • 2010-11-08
          • 2010-10-11
          相关资源
          最近更新 更多