Skip to content

git init compatibility, Git.version() #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ $ pip install --user --upgrade --pre libvcs

<!-- Maintainers, insert changes / features for the next release here -->

### Compatibility

- Add `GitVersionInfo` dataclass and `build_options()` method to `Git` class to
provide structured access to git version information, making version handling more homogeneous
and type-safe (#491). The `version()` method now returns a `Version` object instead of a string.
This allows for more reliable version parsing and comparison, while `GitSync.get_git_version()`
continues to return a string for backward compatibility.

## libvcs 0.35.1 (2025-06-21)

### Bug fixes
Expand Down
21 changes: 21 additions & 0 deletions MIGRATION
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ _Notes on the upcoming release will be added here_

<!-- Maintainers, insert migration notes for the next release here -->

#### Git version handling API changes (#491)

- `Git.version()` now returns a `Version` object instead of a string

Before:

```python
git = Git(path=path)
version_str = git.version() # returns a string like "2.43.0"
```

After:

```python
git = Git(path=path)
version_obj = git.version() # returns a Version object
version_str = ".".join([str(x) for x in (version_obj.major, version_obj.minor, version_obj.micro)])
```

- `GitSync.get_git_version()` continues to return a string for backward compatibility

#### pytest fixtures: `git_local_clone` renamed to `example_git_repo` (#468)

- pytest: `git_local_clone` renamed to `example_git_repo`
Expand Down
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
def add_doctest_fixtures(
request: pytest.FixtureRequest,
doctest_namespace: dict[str, t.Any],
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Configure doctest fixtures for pytest-doctest."""
from _pytest.doctest import DoctestItem
Expand Down
Empty file added src/libvcs/_vendor/__init__.py
Empty file.
63 changes: 63 additions & 0 deletions src/libvcs/_vendor/_structures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# via https://github.com/pypa/packaging/blob/22.0/packaging/_structures.py
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import annotations


class InfinityType:
def __repr__(self) -> str:
return "Infinity"

def __hash__(self) -> int:
return hash(repr(self))

def __lt__(self, other: object) -> bool:
return False

def __le__(self, other: object) -> bool:
return False

def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__)

def __gt__(self, other: object) -> bool:
return True

def __ge__(self, other: object) -> bool:
return True

def __neg__(self: object) -> NegativeInfinityType:
return NegativeInfinity


Infinity = InfinityType()


class NegativeInfinityType:
def __repr__(self) -> str:
return "-Infinity"

def __hash__(self) -> int:
return hash(repr(self))

def __lt__(self, other: object) -> bool:
return True

def __le__(self, other: object) -> bool:
return True

def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__)

def __gt__(self, other: object) -> bool:
return False

def __ge__(self, other: object) -> bool:
return False

def __neg__(self: object) -> InfinityType:
return Infinity


NegativeInfinity = NegativeInfinityType()
Loading