feat(gui): enhance SHA display logic in UpdateDialog
- Introduce a new class method to display the available SHA or indicate "Current" when up to date. - Update the new version label to use the new display method for better clarity. - Adjust the label to show "Current" directly when no pending SHA is available. - Add unit tests to verify the new display logic for available versions.
This commit is contained in:
parent
0a2b8c77b8
commit
fc0170725e
2 changed files with 21 additions and 2 deletions
|
|
@ -533,6 +533,10 @@ class UpdateDialog(QDialog):
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
return sha[:8]
|
return sha[:8]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _available_sha_display(cls, sha: str | None) -> str:
|
||||||
|
return cls._short_sha(sha) if sha else "Current"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _installed_sha_display(cls) -> str:
|
def _installed_sha_display(cls) -> str:
|
||||||
return cls._short_sha(UpdateThread.read_installed_sha())
|
return cls._short_sha(UpdateThread.read_installed_sha())
|
||||||
|
|
@ -588,7 +592,7 @@ class UpdateDialog(QDialog):
|
||||||
self.cancel_btn.setText("Close")
|
self.cancel_btn.setText("Close")
|
||||||
|
|
||||||
tool_sha = self._pending_tool_sha
|
tool_sha = self._pending_tool_sha
|
||||||
self.new_version_label.setText(self._short_sha(tool_sha))
|
self.new_version_label.setText(self._available_sha_display(tool_sha))
|
||||||
|
|
||||||
if not tool_sha:
|
if not tool_sha:
|
||||||
self.headline_label.setText("You're up to date")
|
self.headline_label.setText("You're up to date")
|
||||||
|
|
@ -642,7 +646,7 @@ class UpdateDialog(QDialog):
|
||||||
f"No newer build found on {UpdateThread.REPO_BRANCH}."
|
f"No newer build found on {UpdateThread.REPO_BRANCH}."
|
||||||
)
|
)
|
||||||
self.subtitle_label.setText("You're running the latest version.")
|
self.subtitle_label.setText("You're running the latest version.")
|
||||||
self.new_version_label.setText(self._installed_sha_display())
|
self.new_version_label.setText("Current")
|
||||||
elif message.startswith("updated:"):
|
elif message.startswith("updated:"):
|
||||||
sha = message.split(":", 1)[1]
|
sha = message.split(":", 1)[1]
|
||||||
self._pending_tool_sha = None
|
self._pending_tool_sha = None
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,21 @@ class CheckToolUpdateTests(unittest.TestCase):
|
||||||
self.assertIsNone(check_tool_update())
|
self.assertIsNone(check_tool_update())
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateDialogDisplayTests(unittest.TestCase):
|
||||||
|
def test_available_version_says_current_when_up_to_date(self):
|
||||||
|
from gui.main import UpdateDialog
|
||||||
|
|
||||||
|
self.assertEqual(UpdateDialog._available_sha_display(None), "Current")
|
||||||
|
|
||||||
|
def test_available_version_shows_pending_sha(self):
|
||||||
|
from gui.main import UpdateDialog
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
UpdateDialog._available_sha_display("1234567890abcdef"),
|
||||||
|
"12345678",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AceBundledOnlyTests(unittest.TestCase):
|
class AceBundledOnlyTests(unittest.TestCase):
|
||||||
def _ace_paths(self, base: Path) -> dict:
|
def _ace_paths(self, base: Path) -> dict:
|
||||||
offline = base / "offline"
|
offline = base / "offline"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue