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

Correctly detect changelog entries for prerelease versions #4244

Merged
merged 6 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fix URL with wrong host returned in storage resumable upload (#4374).
- Fixes Firestore emulator transaction expiration and reused bug.
- Fixes Firestore emulator deadlock bug. [#2452](https://github.com/firebase/firebase-tools/issues/2452)
- Improves support for prerelease versions in `ext:dev:publish` (#4244).
4 changes: 3 additions & 1 deletion src/extensions/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ marked.setOptions({
});

const EXTENSIONS_CHANGELOG = "CHANGELOG.md";
const VERSION_LINE_REGEX = /##.*(\d+\.\d+\.\d+).*/;
// Simplifed version of https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
const VERSION_LINE_REGEX =
/##.*(\d+\.\d+\.\d+(?:-((\d+|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(\d+|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?).*/;

/*
* getReleaseNotesForUpdate fetches all version between toVersion and fromVersion and returns the relase notes
Expand Down
3 changes: 2 additions & 1 deletion src/extensions/extensionsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ export async function publishExtensionVersionFromLocalSource(args: {
)
);
}
if (!notes && extension) {
// Skip this check for prerelease versions
if (!notes && !semver.prerelease(extensionSpec.version) && extension) {
// If this is not the first version of this extension, we require release notes
throw new FirebaseError(
`No entry for version ${extensionSpec.version} found in CHANGELOG.md. ` +
Expand Down
8 changes: 8 additions & 0 deletions src/test/extensions/changelog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ describe("changelog", () => {
"0.1.1": "New notes",
},
},
{
description: "should handle prerelease versions",
in: "Some random words\n## Version 0.1.0-rc.1\nNotes\n## Version 0.1.1-release-candidate.1.2\nNew notes",
want: {
"0.1.0-rc.1": "Notes",
"0.1.1-release-candidate.1.2": "New notes",
},
},
];
for (const testCase of testCases) {
it(testCase.description, () => {
Expand Down