Skip to content

Commit 2f04f4f

Browse files
fix: skipSnapshot is not working for java-yoshi (#2562)
1 parent 9b9ccda commit 2f04f4f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/strategies/java-yoshi.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export class JavaYoshi extends Java {
5252
}
5353

5454
protected async needsSnapshot(): Promise<boolean> {
55+
if (this.canSkipSnapshot()) {
56+
return false;
57+
}
5558
return VersionsManifest.needsSnapshot(
5659
(await this.getVersionsContent()).parsedContent
5760
);

src/strategies/java.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ export class Java extends BaseStrategy {
164164
return !version.preRelease || version.preRelease.indexOf('SNAPSHOT') < 0;
165165
}
166166

167+
protected canSkipSnapshot(): boolean {
168+
return this.skipSnapshot;
169+
}
170+
167171
protected async needsSnapshot(
168172
commits: ConventionalCommit[],
169173
latestRelease?: Release
170174
): Promise<boolean> {
171-
if (this.skipSnapshot) {
175+
if (this.canSkipSnapshot()) {
172176
return false;
173177
}
174178

test/strategies/java-yoshi.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,37 @@ describe('JavaYoshi', () => {
133133
);
134134
expect(release!.version?.toString()).to.eql(expectedVersion);
135135
});
136+
137+
it('returns a major/minor version bump PR if skipSnapShot is true', async () => {
138+
const expectedVersion = '0.123.5';
139+
const strategy = new JavaYoshi({
140+
targetBranch: 'main',
141+
github,
142+
component: 'google-cloud-automl',
143+
skipSnapshot: true,
144+
});
145+
sandbox.stub(github, 'findFilesByFilenameAndRef').resolves([]);
146+
const getFileContentsStub = sandbox.stub(
147+
github,
148+
'getFileContentsOnBranch'
149+
);
150+
getFileContentsStub
151+
.withArgs('versions.txt', 'main')
152+
.resolves(
153+
buildGitHubFileContent(fixturesPath, 'versions-released.txt')
154+
);
155+
const latestRelease = {
156+
tag: new TagName(Version.parse('0.123.4'), 'google-cloud-automl'),
157+
sha: 'abc123',
158+
notes: 'some notes',
159+
};
160+
const release = await strategy.buildReleasePullRequest(
161+
COMMITS,
162+
latestRelease
163+
);
164+
expect(release!.version?.toString()).to.eql(expectedVersion);
165+
});
166+
136167
it('handles promotion to 1.0.0', async () => {
137168
const commits = [
138169
...buildMockConventionalCommit(

0 commit comments

Comments
 (0)