Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: backfill latest release with version found in manifest #1131

Merged
merged 2 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,22 @@ export class Manifest {
}

const strategy = strategiesByPath[path];
const latestRelease = releasesByPath[path];
let latestRelease = releasesByPath[path];
if (
!latestRelease &&
this.releasedVersions[path].toString() !== '0.0.0'
) {
const version = this.releasedVersions[path];
const component = await strategy.getComponent();
logger.info(
`No latest release found for path: ${path}, component: ${component}, but a previous version (${version.toString()}) was specified in the manifest.`
);
latestRelease = {
tag: new TagName(version, component),
sha: '',
notes: '',
};
}
const releasePullRequest = await strategy.buildReleasePullRequest(
pathCommits,
latestRelease,
Expand Down
42 changes: 42 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,48 @@ describe('Manifest', () => {
expect(pullRequests[0].version?.toString()).to.eql('1.0.0');
});

it('should read latest version from manifest if no release tag found', async () => {
mockReleases(github, []);
mockCommits(github, [
{
sha: 'aaaaaa',
message: 'fix: some bugfix',
files: ['path/a/foo'],
},
{
sha: 'cccccc',
message: 'fix: some bugfix',
files: ['path/a/foo'],
},
]);
const config = {
packages: {
'path/a': {
'release-type': 'simple',
component: 'pkg1',
},
'path/b': {
'release-type': 'simple',
component: 'pkg2',
},
},
};
const versions = {
'path/a': '1.2.3',
'path/b': '2.3.4',
};
sandbox
.stub(github, 'getFileContentsOnBranch')
.withArgs('release-please-config.json', 'main')
.resolves(buildGitHubFileRaw(JSON.stringify(config)))
.withArgs('.release-please-manifest.json', 'main')
.resolves(buildGitHubFileRaw(JSON.stringify(versions)));
const manifest = await Manifest.fromManifest(github, 'main');
const pullRequests = await manifest.buildPullRequests();
expect(pullRequests).lengthOf(1);
expect(pullRequests[0].version?.toString()).to.eql('1.2.4');
});

describe('with plugins', () => {
beforeEach(() => {
mockReleases(github, [
Expand Down