Skip to content
GitLab
菜单
项目
群组
代码片段
/
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录/注册
切换导航
菜单
打开侧边栏
KMSCAKKSCFKA AKFACAMADCAS
brew
提交
a5781332
提交
a5781332
编辑于
3月 28, 2021
作者:
Markus Reiter
浏览文件
Fix `BundleVersion` comparison when one part is `nil`.
上级
a8f2fd2b
变更
2
Hide whitespace changes
Inline
Side-by-side
Library/Homebrew/bundle_version.rb
浏览文件 @
a5781332
...
...
@@ -10,6 +10,8 @@ module Homebrew
class
BundleVersion
extend
T
::
Sig
include
Comparable
extend
SystemCommand
::
Mixin
sig
{
params
(
info_plist_path:
Pathname
).
returns
(
T
.
nilable
(
T
.
attached_class
))
}
...
...
@@ -55,9 +57,14 @@ module Homebrew
end
def
<
=>
(
other
)
[
version
,
short_version
].
map
{
|
v
|
v
&
.
yield_self
(
&
Version
.
public_method
(
:new
))
}
<=>
[
other
.
version
,
other
.
short_version
].
map
{
|
v
|
v
&
.
yield_self
(
&
Version
.
public_method
(
:new
))
}
[
version
,
short_version
].
map
{
|
v
|
v
&
.
yield_self
(
&
Version
.
public_method
(
:new
))
||
Version
::
NULL
}
<=>
[
other
.
version
,
other
.
short_version
].
map
{
|
v
|
v
&
.
yield_self
(
&
Version
.
public_method
(
:new
))
||
Version
::
NULL
}
end
def
==
(
other
)
instance_of?
(
other
.
class
)
&&
short_version
==
other
.
short_version
&&
version
==
other
.
version
end
alias
eql?
==
# Create a nicely formatted version (on a best effort basis).
sig
{
returns
(
String
)
}
...
...
Library/Homebrew/test/bundle_version_spec.rb
浏览文件 @
a5781332
...
...
@@ -26,4 +26,10 @@ describe Homebrew::BundleVersion do
end
end
end
describe
"#<=>"
do
it
"does not fail when a `version` is nil"
do
expect
(
described_class
.
new
(
"1.06"
,
nil
)).
to
be
<
described_class
.
new
(
"1.12"
,
"1.12"
)
end
end
end
编辑
预览
支持
Markdown
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录