forked from googleapis/release-please
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
141 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {DefaultUpdater} from '../default'; | ||
|
||
export class GoModUpdater extends DefaultUpdater { | ||
updateContent(content: string): string { | ||
if (this.version.major < 2) { | ||
return content; | ||
} | ||
|
||
return content.replace( | ||
/module github\.com\/([^/"\r?\n]+)\/([^/"\r?\n]+)(\/v([1-9]\d*))?/g, | ||
(_, user, repo) => | ||
`module github.com/${user}/${repo}${ | ||
this.version.major < 2 ? '' : '/v' + this.version.major.toString() | ||
}` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/stainless-sdks/meorphis-test-40-go | ||
|
||
go 1.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/stainless-sdks/meorphis-test-40-go/v2 | ||
|
||
go 1.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/stainless-sdks/meorphis-test-40-go/v3 | ||
|
||
go 1.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {readFileSync} from 'fs'; | ||
import {resolve} from 'path'; | ||
import {describe, it} from 'mocha'; | ||
import {expect} from 'chai'; | ||
import {Version} from '../../src/version'; | ||
import {GoModUpdater} from '../../src/updaters/go/go-mod'; | ||
|
||
const fixturesPath = './test/updaters/fixtures/go'; | ||
|
||
describe('GoModUpdater', () => { | ||
describe('go.mod files', () => { | ||
const v1File = readFileSync(resolve(fixturesPath, 'go-v1.mod'), 'utf8'); | ||
const v2File = readFileSync(resolve(fixturesPath, 'go-v2.mod'), 'utf8'); | ||
const v3File = readFileSync(resolve(fixturesPath, 'go-v3.mod'), 'utf8'); | ||
|
||
it('makes no changes if the old version has a major version of 1 and the new version also has a major version of 1', async () => { | ||
const importsUpdater = new GoModUpdater({ | ||
version: Version.parse('1.0.0'), | ||
}); | ||
expect(importsUpdater.updateContent(v1File)).to.equal(v1File); | ||
}); | ||
|
||
it('updates the version in the imports if the old version has a major version of 1 and the new version has a major version of 2', async () => { | ||
const importsUpdater = new GoModUpdater({ | ||
version: Version.parse('2.0.0'), | ||
}); | ||
expect(importsUpdater.updateContent(v1File)).to.equal(v2File); | ||
}); | ||
|
||
it('makes no changes if the old version has a major version of 2 and the new version also has a major version of 2', async () => { | ||
const importsUpdater = new GoModUpdater({ | ||
version: Version.parse('2.0.0'), | ||
}); | ||
expect(importsUpdater.updateContent(v2File)).to.equal(v2File); | ||
}); | ||
|
||
it('updates the version in the imports if the old version has a major version of 2 and the new version has a major version of 3', async () => { | ||
const importsUpdater = new GoModUpdater({ | ||
version: Version.parse('3.0.0'), | ||
}); | ||
expect(importsUpdater.updateContent(v2File)).to.equal(v3File); | ||
}); | ||
}); | ||
}); |