File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -88,14 +88,14 @@ describe('Git commands', () => {
88
88
89
89
const settings = { } as Settings
90
90
settings . gitPath = await io . which ( 'git' , true )
91
- settings . tagRegex = RegExp ( '[0-9]+.[0-9]+.[0-9]+.*' , 'i' )
91
+ settings . tagRegex = RegExp ( '^ [0-9]+.[0-9]+.[0-9]+.*' , 'i' )
92
92
const g = new Git ( settings )
93
93
94
94
await createAndCommitFile ( 'first' , 'First commit' , cwd )
95
95
await createTag ( '0.0.1' , cwd )
96
96
97
97
const tag = await g . currentTag ( )
98
- expect ( tag ) . toEqual ( '' )
98
+ expect ( tag ) . toEqual ( '0.0.1 ' )
99
99
} )
100
100
101
101
it ( 'Verifies previous tag is returned' , async ( ) => {
Original file line number Diff line number Diff line change @@ -18,13 +18,16 @@ export class Git {
18
18
19
19
// In case there are multiple tags get the first valid version tag
20
20
if ( this . settings . tagRegex ) {
21
+ let foundTag = ''
21
22
res . stdout . forEach ( tag => {
22
23
if ( this . settings . tagRegex . test ( tag ) ) {
23
- return tag
24
+ foundTag = tag
25
+ return
24
26
}
25
27
} )
26
- // No tag matched
27
- return ''
28
+
29
+ // Return either matched tag or none
30
+ return foundTag
28
31
}
29
32
// Get the first tag we found if there's no tag regex
30
33
return res . stdout [ 0 ]
You can’t perform that action at this time.
0 commit comments