Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
8f0e9b67
Unverified
Commit
8f0e9b67
authored
Feb 07, 2019
by
Torkel Ödegaard
Committed by
GitHub
Feb 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15282 from CorpGlory/unexpected-semver-comparison-behavior-#15280
Unexpected semver comparison behavior #15280
parents
00a676ff
ee132c10
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
public/app/core/utils/version.ts
+14
-1
public/test/core/utils/version.test.ts
+1
-0
No files found.
public/app/core/utils/version.ts
View file @
8f0e9b67
...
@@ -20,12 +20,25 @@ export class SemVersion {
...
@@ -20,12 +20,25 @@ export class SemVersion {
isGtOrEq
(
version
:
string
):
boolean
{
isGtOrEq
(
version
:
string
):
boolean
{
const
compared
=
new
SemVersion
(
version
);
const
compared
=
new
SemVersion
(
version
);
return
!
(
this
.
major
<
compared
.
major
||
this
.
minor
<
compared
.
minor
||
this
.
patch
<
compared
.
patch
);
for
(
let
i
=
0
;
i
<
this
.
comparable
.
length
;
++
i
)
{
if
(
this
.
comparable
[
i
]
>
compared
.
comparable
[
i
])
{
return
true
;
}
if
(
this
.
comparable
[
i
]
<
compared
.
comparable
[
i
])
{
return
false
;
}
}
return
true
;
}
}
isValid
():
boolean
{
isValid
():
boolean
{
return
_
.
isNumber
(
this
.
major
);
return
_
.
isNumber
(
this
.
major
);
}
}
get
comparable
()
{
return
[
this
.
major
,
this
.
minor
,
this
.
patch
];
}
}
}
export
function
isVersionGtOrEq
(
a
:
string
,
b
:
string
):
boolean
{
export
function
isVersionGtOrEq
(
a
:
string
,
b
:
string
):
boolean
{
...
...
public/test/core/utils/version
_
test.ts
→
public/test/core/utils/version
.
test.ts
View file @
8f0e9b67
...
@@ -44,6 +44,7 @@ describe('SemVersion', () => {
...
@@ -44,6 +44,7 @@ describe('SemVersion', () => {
{
values
:
[
'3.1.1-beta1'
,
'3.1'
],
expected
:
true
},
{
values
:
[
'3.1.1-beta1'
,
'3.1'
],
expected
:
true
},
{
values
:
[
'3.4.5'
,
'4'
],
expected
:
false
},
{
values
:
[
'3.4.5'
,
'4'
],
expected
:
false
},
{
values
:
[
'3.4.5'
,
'3.5'
],
expected
:
false
},
{
values
:
[
'3.4.5'
,
'3.5'
],
expected
:
false
},
{
values
:
[
'6.0.0'
,
'5.2.0'
],
expected
:
true
},
];
];
cases
.
forEach
(
testCase
=>
{
cases
.
forEach
(
testCase
=>
{
expect
(
isVersionGtOrEq
(
testCase
.
values
[
0
],
testCase
.
values
[
1
])).
toBe
(
testCase
.
expected
);
expect
(
isVersionGtOrEq
(
testCase
.
values
[
0
],
testCase
.
values
[
1
])).
toBe
(
testCase
.
expected
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment