Skip to content

Commit

Permalink
Fix a bug causing the release notes viewer to always show (#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Aug 29, 2024
1 parent cd729bd commit 6660b55
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class ReleaseNotesController extends SidePanelController {
if (server.isDevToolsServerAvailable) {
final lastReleaseNotesShownVersion =
await server.getLastShownReleaseNotesVersion();
_log.fine('lastReleaseNotesShownVersion: $lastReleaseNotesShownVersion');
if (lastReleaseNotesShownVersion.isNotEmpty) {
previousVersion = SemanticVersion.parse(lastReleaseNotesShownVersion);
}
Expand Down Expand Up @@ -119,10 +120,16 @@ class ReleaseNotesController extends SidePanelController {
// strip off any build metadata (any characters following a '+' character).
// Release notes will be hosted on the Flutter website with a version number
// that does not contain any build metadata.
final parsedVersion = SemanticVersion.parse(devToolsVersion);
final notesVersion = latestVersionToCheckForReleaseNotes(parsedVersion);
final parsedDevToolsVersion = SemanticVersion.parse(devToolsVersion);
final checkVersion =
latestVersionToCheckForReleaseNotes(parsedDevToolsVersion);

if (notesVersion <= versionFloor) {
_log.fine(
'attempting to fetch and show release notes for DevTools $checkVersion '
'with version floor $versionFloor.',
);

if (checkVersion <= versionFloor) {
// If the current version is equal to or below the version floor,
// no need to show the release notes.
_emptyAndClose();
Expand All @@ -134,23 +141,30 @@ class ReleaseNotesController extends SidePanelController {
return;
}

// If the version floor has the same major and minor version,
// don't check below its patch version.
// If the version floor has the same major and minor version as the version
// we are checking for, don't check below the version floor's patch version.
final int minimumPatch;
if (versionFloor.major == notesVersion.major &&
versionFloor.minor == notesVersion.minor) {
if (versionFloor.major == checkVersion.major &&
versionFloor.minor == checkVersion.minor) {
minimumPatch = versionFloor.patch;
} else {
minimumPatch = 0;
}

final majorMinor = '${notesVersion.major}.${notesVersion.minor}';
var patchToCheck = notesVersion.patch;
final majorMinor = '${checkVersion.major}.${checkVersion.minor}';
var patchToCheck = checkVersion.patch;

// Try each patch version in this major.minor combination until we find
// release notes (e.g. 2.11.4 -> 2.11.3 -> 2.11.2 -> ...).
while (patchToCheck >= minimumPatch) {
final releaseToCheck = '$majorMinor.$patchToCheck';

final releaseToCheckVersion = SemanticVersion.parse(releaseToCheck);
if (releaseToCheckVersion <= versionFloor) {
_emptyAndClose();
return;
}

if (releases[releaseToCheck] case final releaseNotePath?) {
final String releaseNotesMarkdown;
try {
Expand All @@ -175,8 +189,7 @@ class ReleaseNotesController extends SidePanelController {

toggleVisibility(true);
if (server.isDevToolsServerAvailable) {
// Only set the last release notes version
// if we are not debugging.
// Only set the last release notes version if we are not debugging.
unawaited(
server.setLastShownReleaseNotesVersion(releaseToCheck),
);
Expand All @@ -188,7 +201,7 @@ class ReleaseNotesController extends SidePanelController {
}

_emptyAndClose(
'Could not find release notes for DevTools version $notesVersion.',
'Could not find release notes for DevTools version $checkVersion.',
);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ To learn more about DevTools, check out the

## General updates

TODO: Remove this section if there are not any general updates.
* Fixed a bug that was causing the DevTools release notes to always
show. - [#8277](https://github.com/flutter/devtools/pull/8277)

## Inspector updates

Expand Down

0 comments on commit 6660b55

Please sign in to comment.