Skip to content

Commit a494c2a

Browse files
committed
fix: fix an issue with release please not updating full version of go dependency
Signed-off-by: Jonas Kalderstam <[email protected]>
1 parent e83e833 commit a494c2a

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

src/updaters/go/go-mod.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export class GoMod extends DefaultUpdater {
3232
}
3333

3434
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');
3638
// Is the dep in the go.mod file?
3739
const deps = regex.exec(payload);
3840

src/updaters/go/version-go.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {DefaultUpdater} from '../default';
1717
export class VersionGo extends DefaultUpdater {
1818
updateContent(content: string): string {
1919
return content.replace(
20-
/const Version = "[0-9]+\.[0-9]+\.[0-9](-\w+)?"/,
20+
/const Version = "\d+\.\d+\.\d[^\s]*"/,
2121
`const Version = "${this.version.toString()}"`
2222
);
2323
}

test/updaters/fixtures/go/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ replace example.com/foo/bar/v2 => ../../foo/bar
77
require (
88
example.com/foo/bar/v2 v2.1.0
99
example.com/foo/baz v1.2.3
10+
example.com/car/dar v0.1.1-0.20250203122516-4c838e530ecb
1011
)

test/updaters/go-mod.ts

+15
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ describe('go.mod', () => {
4848
Version.parse('v1.2.4')
4949
);
5050

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+
5166
const updater = new GoMod({
5267
version: Version.parse('v2.3.4'),
5368
versionsMap: updatedVersions,

0 commit comments

Comments
 (0)