From c62a51d5bce908b7a8881f354bb2a9ea0ae67c70 Mon Sep 17 00:00:00 2001 From: Chuck Danielsson Date: Sun, 29 Jun 2025 21:25:57 -0400 Subject: [PATCH 1/3] 0.1.4 --- VERSION | 2 +- lbranch/version.py | 5 +---- mise.toml | 4 ++-- pyproject.toml | 7 ++++++- test/test_version.py | 38 ++++++++++++++++++++++++++++++++++++++ update-version.sh | 17 ++++++++++++++--- 6 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 test/test_version.py diff --git a/VERSION b/VERSION index b1e80bb..845639e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.3 +0.1.4 diff --git a/lbranch/version.py b/lbranch/version.py index a1df734..3944b9e 100644 --- a/lbranch/version.py +++ b/lbranch/version.py @@ -1,6 +1,3 @@ """Version information for lbranch.""" -from pathlib import Path - -_version_file = Path(__file__).parent.parent / 'VERSION' -__version__ = _version_file.read_text().strip() +__version__ = '0.1.4' diff --git a/mise.toml b/mise.toml index bd0d914..5f49e91 100644 --- a/mise.toml +++ b/mise.toml @@ -16,5 +16,5 @@ format = "ruff format ." # Ideal for CI pipelines to verify consistent formatting format-check = "ruff format --check ." -# Test: Run the unittest suite -test = "python -m unittest test/test_lbranch.py" \ No newline at end of file +# Test: Run the test suite with pytest +test = "python -m pytest" diff --git a/pyproject.toml b/pyproject.toml index 24e8c2e..3a1a658 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "lbranch" -version = "0.1.3" +version = "0.1.4" description = "A Git utility that shows recently checked-out branches in chronological order and lets you quickly switch between them." readme = "README.md" requires-python = ">=3.7" @@ -62,3 +62,8 @@ exclude = [ # Use single quotes for consistency quote-style = "single" line-ending = "auto" + +[tool.pytest.ini_options] +# Suppress pytest-asyncio warning since we don't use async +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "function" diff --git a/test/test_version.py b/test/test_version.py new file mode 100644 index 0000000..0caf26e --- /dev/null +++ b/test/test_version.py @@ -0,0 +1,38 @@ +"""Test version consistency across files.""" + +import pytest +from pathlib import Path +from lbranch.version import __version__ + + +def test_version_consistency(): + """Verify version is consistent between VERSION file and version.py.""" + # Read VERSION file + version_file = Path(__file__).parent.parent / 'VERSION' + file_version = version_file.read_text().strip() + + # Compare with hardcoded version + assert __version__ == file_version, ( + f"Version mismatch: version.py has '{__version__}' " + f"but VERSION file has '{file_version}'" + ) + + +def test_pyproject_version_consistency(): + """Verify version is consistent between pyproject.toml and version.py.""" + # Read pyproject.toml + pyproject_file = Path(__file__).parent.parent / 'pyproject.toml' + pyproject_content = pyproject_file.read_text() + + # Extract version from pyproject.toml + import re + match = re.search(r'^version = "(.+)"', pyproject_content, re.MULTILINE) + assert match, "Could not find version in pyproject.toml" + + pyproject_version = match.group(1) + + # Compare with hardcoded version + assert __version__ == pyproject_version, ( + f"Version mismatch: version.py has '{__version__}' " + f"but pyproject.toml has '{pyproject_version}'" + ) \ No newline at end of file diff --git a/update-version.sh b/update-version.sh index a13c74f..9148ecd 100755 --- a/update-version.sh +++ b/update-version.sh @@ -28,6 +28,17 @@ if [ -f pyproject.toml ]; then echo "✓ Updated pyproject.toml to $NEW_VERSION" fi -echo "✓ Version updated to $NEW_VERSION in all files" -echo "" -echo "Python files now read version from VERSION file automatically." \ No newline at end of file +# Update lbranch/version.py +if [ -f lbranch/version.py ]; then + # Use sed to update the version line + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS requires backup extension + sed -i '' "s/__version__ = '.*'/__version__ = '$NEW_VERSION'/" lbranch/version.py + else + # Linux + sed -i "s/__version__ = '.*'/__version__ = '$NEW_VERSION'/" lbranch/version.py + fi + echo "✓ Updated lbranch/version.py to $NEW_VERSION" +fi + +echo "✓ Version updated to $NEW_VERSION in all files" \ No newline at end of file From c58015cd8eabdc63e14c6adb937fef084d05547c Mon Sep 17 00:00:00 2001 From: Chuck Danielsson Date: Sun, 29 Jun 2025 21:28:17 -0400 Subject: [PATCH 2/3] lint and format --- test/test_version.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/test_version.py b/test/test_version.py index 0caf26e..1bd2c24 100644 --- a/test/test_version.py +++ b/test/test_version.py @@ -1,7 +1,7 @@ """Test version consistency across files.""" -import pytest from pathlib import Path + from lbranch.version import __version__ @@ -10,7 +10,7 @@ def test_version_consistency(): # Read VERSION file version_file = Path(__file__).parent.parent / 'VERSION' file_version = version_file.read_text().strip() - + # Compare with hardcoded version assert __version__ == file_version, ( f"Version mismatch: version.py has '{__version__}' " @@ -23,16 +23,17 @@ def test_pyproject_version_consistency(): # Read pyproject.toml pyproject_file = Path(__file__).parent.parent / 'pyproject.toml' pyproject_content = pyproject_file.read_text() - + # Extract version from pyproject.toml import re + match = re.search(r'^version = "(.+)"', pyproject_content, re.MULTILINE) - assert match, "Could not find version in pyproject.toml" - + assert match, 'Could not find version in pyproject.toml' + pyproject_version = match.group(1) - + # Compare with hardcoded version assert __version__ == pyproject_version, ( f"Version mismatch: version.py has '{__version__}' " f"but pyproject.toml has '{pyproject_version}'" - ) \ No newline at end of file + ) From 73bf8fd92dd6efb500a568a644501e069406f085 Mon Sep 17 00:00:00 2001 From: Chuck Danielsson Date: Sun, 29 Jun 2025 21:36:26 -0400 Subject: [PATCH 3/3] install pytest --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ba56d9..3c48904 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,9 @@ jobs: - name: Setup dependencies with mise run: mise install + - name: Install pytest + run: pip install pytest + - name: Run ruff linter run: mise run lint