Skip to content

Commit 70d3a6e

Browse files
committed
docs(README): Add example to front page
1 parent 9bf649d commit 70d3a6e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Features for Git, Subversion, and Mercurial:
1111
- **Detect and parse** VCS URLs
1212
- **Command** VCS via python API
1313
- **Sync** repos locally
14+
- **Test fixtures** for temporary local repos and working copies
1415

1516
To **get started**, see the [quickstart](https://libvcs.git-pull.com/quickstart.html) for more.
1617

@@ -109,6 +110,43 @@ repo = GitSync(
109110
u'5c227e6ab4aab44bf097da2e088b0ff947370ab8'
110111
```
111112

113+
## Pytest plugin
114+
115+
libvcs also provides a test rig for local repositories. It automatically can provide clean local
116+
repositories and working copies for git, svn, and mercurial. They are automatically cleaned up after
117+
each test.
118+
119+
It works by bootstrapping a temporary `$HOME` environment in a
120+
[`TmpPathFactory`](https://docs.pytest.org/en/7.1.x/reference/reference.html#tmp-path-factory-factory-api)
121+
for automatic cleanup.
122+
123+
```python
124+
import pathlib
125+
126+
from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
127+
from libvcs.sync.git import GitSync
128+
129+
130+
def test_repo_git_remote_checkout(
131+
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
132+
tmp_path: pathlib.Path,
133+
projects_path: pathlib.Path,
134+
) -> None:
135+
git_server = create_git_remote_repo()
136+
git_repo_checkout_dir = projects_path / "my_git_checkout"
137+
git_repo = GitSync(dir=str(git_repo_checkout_dir), url=f"file://{git_server!s}")
138+
139+
git_repo.obtain()
140+
git_repo.update_repo()
141+
142+
assert git_repo.get_revision() == "initial"
143+
144+
assert git_repo_checkout_dir.exists()
145+
assert pathlib.Path(git_repo_checkout_dir / ".git").exists()
146+
```
147+
148+
Learn more on the docs at https://libvcs.git-pull.com/pytest-plugin.html
149+
112150
## Donations
113151

114152
Your donations fund development of new features, testing and support. Your money will go directly to

0 commit comments

Comments
 (0)