File tree 4 files changed +20
-2
lines changed
4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ export class GoMod extends DefaultUpdater {
32
32
}
33
33
34
34
for ( const [ pkgName , pkgVersion ] of this . versionsMap ) {
35
- const regex = new RegExp ( `${ pkgName } v\\d+\\.\\d+\\.\\d+` , 'g' ) ;
35
+ // Easy version is v1.2.3
36
+ // But if depending on a commit it could be v0.1.1-0.20250203122516-4c838e530ecb
37
+ const regex = new RegExp ( `${ pkgName } v\\d+\\.\\d+\\.\\d+[^\\s]*` , 'g' ) ;
36
38
// Is the dep in the go.mod file?
37
39
const deps = regex . exec ( payload ) ;
38
40
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import {DefaultUpdater} from '../default';
17
17
export class VersionGo extends DefaultUpdater {
18
18
updateContent ( content : string ) : string {
19
19
return content . replace (
20
- / c o n s t V e r s i o n = " [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] ( - \w + ) ? " / ,
20
+ / c o n s t V e r s i o n = " \d + \. \d + \. \d [ ^ \s ] * " / ,
21
21
`const Version = "${ this . version . toString ( ) } "`
22
22
) ;
23
23
}
Original file line number Diff line number Diff line change @@ -7,4 +7,5 @@ replace example.com/foo/bar/v2 => ../../foo/bar
7
7
require (
8
8
example.com/foo/bar/v2 v2.1.0
9
9
example.com/foo/baz v1.2.3
10
+ example.com/car/dar v0.1.1-0.20250203122516-4c838e530ecb
10
11
)
Original file line number Diff line number Diff line change @@ -48,6 +48,21 @@ describe('go.mod', () => {
48
48
Version . parse ( 'v1.2.4' )
49
49
) ;
50
50
51
+ const updater = new GoMod ( {
52
+ version : Version . parse ( 'v2.3.4' ) ,
53
+ versionsMap : updatedVersions ,
54
+ } ) ;
55
+ const newContent = updater . updateContent ( oldContent ) ;
56
+ snapshot ( newContent ) ;
57
+ } ) ;
58
+ it ( 'updates a commit dependency' , async ( ) => {
59
+ const oldContent = readFileSync (
60
+ resolve ( fixturesPath , './go.mod' ) ,
61
+ 'utf8'
62
+ ) . replace ( / \r \n / g, '\n' ) ;
63
+ const updatedVersions = new Map ( ) ;
64
+ updatedVersions . set ( 'example.com/car/dar' , Version . parse ( 'v0.1.2' ) ) ;
65
+
51
66
const updater = new GoMod ( {
52
67
version : Version . parse ( 'v2.3.4' ) ,
53
68
versionsMap : updatedVersions ,
You can’t perform that action at this time.
0 commit comments