File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,21 @@ export function makeHelper(version) {
16
16
hash . versionOnly = hash . versionOnly || hash . hideSha ;
17
17
hash . shaOnly = hash . shaOnly || hash . hideVersion ;
18
18
19
+ let match = null ;
20
+
19
21
if ( hash . versionOnly ) {
20
22
if ( hash . showExtended ) {
21
- return version . match ( versionExtendedRegExp ) [ 0 ] ; // 1.0.0-alpha.1
23
+ match = version . match ( versionExtendedRegExp ) ; // 1.0.0-alpha.1
22
24
} else {
23
- return version . match ( versionRegExp ) [ 0 ] ; // 1.0.0
25
+ match = version . match ( versionRegExp ) ; // 1.0.0
24
26
}
25
27
}
26
28
27
29
if ( hash . shaOnly ) {
28
- return version . match ( shaRegExp ) [ 0 ] ; // 4jds75hf
30
+ match = version . match ( shaRegExp ) ; // 4jds75hf
29
31
}
30
32
31
- return version ;
33
+ return match ? match [ 0 ] : version ;
32
34
} ;
33
35
}
34
36
Original file line number Diff line number Diff line change @@ -15,12 +15,12 @@ test('version reg ex matches expected strings', function(assert) {
15
15
test ( 'version extended reg ex matches expected strings' , function ( assert ) {
16
16
assert . expect ( 6 ) ;
17
17
18
- assert . ok ( '2.0.1-alpha' . match ( versionRegExp ) , 'Matches expected pattern.' ) ;
19
- assert . ok ( '2.20.1-alpha.15' . match ( versionRegExp ) , 'Matches expected pattern.' ) ;
20
- assert . ok ( ! '1.1.1-alpha.' . match ( versionRegExp ) , 'Does not match hanging period.' ) ;
21
- assert . ok ( ! '1.1.1-alpha.abc' . match ( versionRegExp ) , 'Does not match letters after extended tag period.' ) ;
22
- assert . ok ( ! 'a.b.c-alpha.15' . match ( versionRegExp ) , 'Does not match letters.' ) ;
23
- assert . ok ( ! 'git12sha' . match ( versionRegExp ) , 'Does not match sha.' ) ;
18
+ assert . ok ( '2.0.1-alpha' . match ( versionExtendedRegExp ) , 'Matches expected pattern.' ) ;
19
+ assert . ok ( '2.20.1-alpha.15' . match ( versionExtendedRegExp ) , 'Matches expected pattern.' ) ;
20
+ assert . ok ( ! '1.1.1-alpha.' . match ( versionExtendedRegExp ) , 'Does not match hanging period.' ) ;
21
+ assert . ok ( ! '1.1.1-alpha.abc' . match ( versionExtendedRegExp ) , 'Does not match letters after extended tag period.' ) ;
22
+ assert . ok ( ! 'a.b.c-alpha.15' . match ( versionExtendedRegExp ) , 'Does not match letters.' ) ;
23
+ assert . ok ( ! 'git12sha' . match ( versionExtendedRegExp ) , 'Does not match sha.' ) ;
24
24
} ) ;
25
25
26
26
test ( 'git sha reg ex matches expected strings' , function ( assert ) {
You can’t perform that action at this time.
0 commit comments