fix: query installed_version("google-colab-cli") after PyPI rename (#21)

The rename in #20 (colab -> google-colab-cli) missed get_app_version() in src/colab_cli/auto_update.py, which still asked importlib.metadata for the old distribution name. After install from the renamed PyPI package, the lookup raised PackageNotFoundError and the function silently fell through to the git-rev-parse fallback; inside an install venv with no git repo that also fails and the user saw "Version: unknown" from `colab version` (and the same broken value flowed into the auto-update banner's "current vs latest" comparison). Existing test_version.py tests mocked installed_version directly so they didn't catch the wrong argument. Strengthen test_version_installed with mock_version.assert_called_with("google-colab-cli") so a future rename can't silently regress this again. Verified by building a wheel and installing into a fresh venv: `colab version` now prints the package version instead of "unknown".

Tyler committed May 26, 2026 at 10:20 UTC 89aebba652e4794769190eb54894834f11f089a3
2 files changed +5 -1
src/colab_cli/auto_update.py
+1 -1
@@ -42,7 +42,7 @@ from colab_cli.state import Settings
42 def get_app_version() -> str:
43 """Return the installed package version, falling back to the git short hash."""
44 try:
45 - return installed_version("colab")
45 + return installed_version("google-colab-cli")
46 except (PackageNotFoundError, InvalidVersion):
47 pass
48
tests/test_version.py
+4
@@ -27,6 +27,10 @@ def test_version_installed():
27 result = runner.invoke(app, ["version"])
28 assert result.exit_code == 0
29 assert "Version: 0.2.0" in result.output
30 + # Guard against a silent regression if the PyPI distribution name
31 + # changes again: importlib.metadata.version() must be called with
32 + # the distribution name exactly as it appears in pyproject.toml.
33 + mock_version.assert_called_with("google-colab-cli")
34
35
36 def test_version_git_fallback():