Skip to content

refactor!: move to libvcs.states #318

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

Merged
merged 3 commits into from
Apr 4, 2022
Merged
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
15 changes: 10 additions & 5 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ $ pip install --user --upgrade --pre libvcs

## libvcs 0.12.0 (unreleased, beta 0)

### Breaking

- `GitRepo`, `SVNRepo`, `MercurialRepo`, `BaseRepo` have been moved to
`libvcs.states.{module}.{Module}Repo`

### What's new

- {class}`libvcs.git.GitRepo` now accepts remotes in `__init__`
- {class}`libvcs.states.git.GitRepo` now accepts remotes in `__init__`

```python
repo = GitRepo(
Expand All @@ -38,7 +43,7 @@ $ pip install --user --upgrade --pre libvcs
)
```

- {meth}`libvcs.git.GitRepo.update_repo` now accepts `set_remotes=True`
- {meth}`libvcs.states.git.GitRepo.update_repo` now accepts `set_remotes=True`

### Compatibility

Expand All @@ -55,9 +60,9 @@ $ pip install --user --upgrade --pre libvcs
[@actions/setup v3.1](https://github.com/actions/setup-python/releases/tag/v3.1.0), (:issue:`316`)
- New constants for `str` -> class mappings

- {data}`libvcs.constants.DEFAULT_VCS_CLASS_MAP`
- {data}`libvcs.constants.DEFAULT_VCS_CLASS_UNION`
- {data}`libvcs.constants.DEFAULT_VCS_LITERAL`
- {data}`libvcs.states.constants.DEFAULT_VCS_CLASS_MAP`
- {data}`libvcs.states.constants.DEFAULT_VCS_CLASS_UNION`
- {data}`libvcs.states.constants.DEFAULT_VCS_LITERAL`

- Remove tox and tox-poetry-installer. It turns out installing poetry inside a poetry project
doesn't work well. (`poetry update`, `poetry publish`, etc. commands would fail)
Expand Down
17 changes: 0 additions & 17 deletions docs/api/git.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:hidden:

quickstart
api/index
states/index
```

```{toctree}
Expand Down
6 changes: 5 additions & 1 deletion docs/redirects.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"api.md" "api/index.md"
"api.md" "states/index.md"
"api/base.md" "states/base.md"
"api/git.md" "states/git.md"
"api/hg.md" "states/hg.md"
"api/svn.md" "states/svn.md"
8 changes: 5 additions & 3 deletions docs/api/base.md → docs/states/base.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Base objects
# `libvcs.states.base`

Base objects / classes for states.

Adding your own VCS / Extending libvcs can be done through subclassing `BaseRepo`.

```{eval-rst}
.. autosummary::
:recursive:

libvcs.base.BaseRepo
libvcs.states.base.BaseRepo
```

```{eval-rst}
.. automodule:: libvcs.base
.. automodule:: libvcs.states.base
:members:
:show-inheritance:
```
24 changes: 24 additions & 0 deletions docs/states/git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# `libvcs.states.git`

For `git(1)`.

Compare to:
[`fabtools.require.git`](https://fabtools.readthedocs.io/en/0.19.0/api/require/git.html),
[`salt.states.git`](https://docs.saltproject.io/en/latest/ref/states/all/salt.states.git.html),
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)

```{eval-rst}
.. autosummary::
:recursive:

libvcs.states.git.GitRemote
libvcs.states.git.GitRepo
```

```{eval-rst}
.. automodule:: libvcs.states.git
:members:
:show-inheritance:
:undoc-members:
:inherited-members:
```
8 changes: 4 additions & 4 deletions docs/api/hg.md → docs/states/hg.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Mercurial (hg)
# `libvcs.states.hg`

aka `hg(1)`
For mercurial, aka `hg(1)`.

```{eval-rst}
.. autosummary::
:recursive:

libvcs.hg.MercurialRepo
libvcs.states.hg.MercurialRepo
```

```{eval-rst}
.. automodule:: libvcs.hg
.. automodule:: libvcs.states.hg
:members:
:show-inheritance:
:undoc-members:
Expand Down
11 changes: 8 additions & 3 deletions docs/api/index.md → docs/states/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
(api)=
(states)=

# API Reference
# `libvcs.states`

Compare to:
[`fabtools.require.git`](https://fabtools.readthedocs.io/en/0.19.0/api/require/git.html),
[`salt.states.git`](https://docs.saltproject.io/en/latest/ref/states/all/salt.states.git.html),
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)

:::{warning}

Expand Down Expand Up @@ -33,7 +38,7 @@ See examples below of git, mercurial, and subversion.
## Constants

```{eval-rst}
.. automodule:: libvcs.constants
.. automodule:: libvcs.states.constants
:members:
```

Expand Down
8 changes: 4 additions & 4 deletions docs/api/svn.md → docs/states/svn.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Subversion (svn)
# `libvcs.states.svn`

aka `svn(1)`
For subversion, aka `svn(1)`

```{eval-rst}
.. autosummary::
:recursive:

libvcs.svn.SubversionRepo
libvcs.states.svn.SubversionRepo
```

```{eval-rst}
.. automodule:: libvcs.svn
.. automodule:: libvcs.states.svn
:members:
:show-inheritance:
:undoc-members:
Expand Down
9 changes: 5 additions & 4 deletions libvcs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Repo package for libvcs."""
import logging

from .base import BaseRepo, RepoLoggingAdapter
from .git import GitRepo
from .hg import MercurialRepo
from .svn import SubversionRepo
from .states.base import BaseRepo
from .states.git import GitRepo
from .states.hg import MercurialRepo
from .states.svn import SubversionRepo
from .util import RepoLoggingAdapter

__all__ = [
"GitRepo",
Expand Down
2 changes: 1 addition & 1 deletion libvcs/base.py → libvcs/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import NamedTuple
from urllib import parse as urlparse

from .util import RepoLoggingAdapter, mkdir_p, run
from ..util import RepoLoggingAdapter, mkdir_p, run

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions libvcs/git.py → libvcs/states/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from typing import Dict, NamedTuple, Optional, TypedDict, Union
from urllib import parse as urlparse

from . import exc
from .base import BaseRepo, VCSLocation, convert_pip_url as base_convert_pip_url
from .. import exc
from ..states.base import BaseRepo, VCSLocation, convert_pip_url as base_convert_pip_url

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_base.py → tests/states/test_base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""tests for libvcs repo abstract base class."""
import pathlib

from libvcs.base import BaseRepo, convert_pip_url
from libvcs.shortcuts import create_repo
from libvcs.states.base import BaseRepo, convert_pip_url


def test_repr():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_git.py → tests/states/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from pytest_mock import MockerFixture

from libvcs import exc
from libvcs.git import (
from libvcs.shortcuts import create_repo_from_pip_url
from libvcs.states.git import (
FullRemoteDict,
GitRemote,
GitRepo,
convert_pip_url as git_convert_pip_url,
extract_status,
)
from libvcs.shortcuts import create_repo_from_pip_url
from libvcs.util import run, which

if not which("git"):
Expand Down
File renamed without changes.
File renamed without changes.