Skip to content

Commit

Permalink
Correctly detect changelog entries for prerelease versions (#4244)
Browse files Browse the repository at this point in the history
* Fix bug where changelogs would not been detected correctl for prerelease version, and skips changleog check for prerelease versions

* typo fix

* wording fix
  • Loading branch information
joehan committed Apr 8, 2022
1 parent 3d43bae commit 418bf36
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- 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).
- Fixes console error on large uploads to Storage Emulator (#4407).
- Fixes cross-platform incompatibility with Storage Emulator exports (#4411).
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

0 comments on commit 418bf36

Please sign in to comment.