FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: expose the release version in editable imports · gitpython-developers/GitPython@1074925 · GitHub

Repository navigation

Commit 1074925

Browse files
authored andcommitted
fix: expose the release version in editable imports
Salt parses `git.__version__` when enabling its GitPython provider. Source imports retain the build placeholder `"git"`, so an editable installation reports valid distribution metadata but Salt rejects the provider and skips its real fileserver tests. Read the checkout's `VERSION` only when the public value is still unstamped. Built wheels and source distributions continue to use the existing release stamping; repository discovery and backend selection are unchanged. The regression failed with `"git"` before this change. All 34 downstream compatibility regressions pass with both CLI and Gix. Ruff lint/format, mypy for `git/__init__.py`, and `git diff --check` pass.
1 parent 15f7696 commit 1074925

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎doc/source/changes.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Git executable and safety
5151
API changes
5252
-----------
5353

54+
* Editable/source imports expose the release version in ``git.__version__``,
55+
matching built distributions. Salt's GitPython provider checks can parse the
56+
version instead of rejecting the unstamped ``"git"`` build placeholder.
5457
* ``Repo`` construction validates repository configuration through Git/Gix.
5558
A subclass override of ``config_reader()`` no longer controls discovery or
5659
suppresses its include graph. Malformed configuration and invalid repository

‎git/__init__.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
]
8282

8383
__version__ = "git"
84+
if __version__ == "git":
85+
# Wheels and source distributions stamp this value; editable imports do not.
86+
from pathlib import Path as _Path
87+
88+
__version__ = (_Path(__file__).resolve().parents[1] / "VERSION").read_text(encoding="utf-8").strip()
8489

8590
from typing import Optional as _Optional
8691

‎test/test_downstream_compatibility.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Public GitPython queries used by released downstream projects."""
22

33
from pathlib import Path
4+
from importlib.metadata import version
45

56
import pytest
67

@@ -10,6 +11,10 @@
1011
from test.lib.fixtures import fixture_repo, read_only_fixture
1112

1213

14+
def test_public_version_supports_downstream_provider_checks():
15+
assert git.__version__ == version("GitPython")
16+
17+
1318
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
1419
@pytest.mark.parametrize("ref_format", ["files", "reftable"])
1520
def test_repo_accepts_explicit_literal_path_selection(object_format, ref_format, monkeypatch):

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL