@@ -6,27 +6,28 @@ detection and parsing of URLs, commanding, and syncing with `git`, `hg`, and `sv
6
6
7
7
## Overview
8
8
9
- _ Supports Python 3.9 and above _
9
+ ### Key Features
10
10
11
- Features for Git, Subversion, and Mercurial:
11
+ - ** URL Detection and Parsing** : Validate and parse Git, Mercurial, and Subversion URLs.
12
+ - ** Command Abstraction** : Interact with VCS systems through a Python API.
13
+ - ** Repository Synchronization** : Clone and update repositories locally via
14
+ Python API.
15
+ - ** py.test fixtures** : Create temporary local repositories and working copies for testing for unit tests.
12
16
13
- - ** Detect and parse** VCS URLs
14
- - ** Command** VCS via python API
15
- - ** Sync** repos locally
16
- - ** Test fixtures** for temporary local repos and working copies
17
+ _ Supports Python 3.9 and above, Git (including AWS CodeCommit), Subversion, and Mercurial._
17
18
18
- To ** get started** , see the [ quickstart] ( https://libvcs.git-pull.com/quickstart.html ) for more.
19
+ To ** get started** , see the [ quickstart guide ] ( https://libvcs.git-pull.com/quickstart.html ) for more information .
19
20
20
21
``` console
21
22
$ pip install --user libvcs
22
23
```
23
24
24
- ## URL Parser
25
+ ## URL Detection and Parsing
25
26
26
- You can validate and parse Git, Mercurial, and Subversion URLs through
27
- [ ` libvcs.url ` ] ( https://libvcs.git-pull.com/url/index.html ) :
27
+ Easily validate and parse VCS URLs using the
28
+ [ ` libvcs.url ` ] ( https://libvcs.git-pull.com/url/index.html ) module :
28
29
29
- Validate:
30
+ ### Validate URLs
30
31
31
32
``` python
32
33
>> > from libvcs.url.git import GitURL
@@ -35,7 +36,7 @@ Validate:
35
36
True
36
37
```
37
38
38
- Parse and adjust a Git URL :
39
+ ### Parse and adjust Git URLs :
39
40
40
41
``` python
41
42
>> > from libvcs.url.git import GitURL
@@ -73,11 +74,11 @@ Switch repo libvcs -> vcspull:
73
74
74
75
See more in the [ parser document] ( https://libvcs.git-pull.com/parse/index.html ) .
75
76
76
- ## Commands
77
+ ## Command Abstraction
77
78
78
- Simple [ ` subprocess ` ] ( https://docs.python.org/3/library/subprocess.html ) wrappers around ` git(1) ` ,
79
- ` hg(1) ` , ` svn(1) ` . Here is [ ` Git ` ] ( https://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git ) w/
80
- [ ` Git.clone ` ] ( http://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git. Git.clone ) :
79
+ Abstracts CLI commands for ` git(1) ` , ` hg(1) ` , ` svn(1) ` via a lightweight [ ` subprocess ` ] ( https://docs.python.org/3/library/subprocess.html ) wrapper.
80
+
81
+ ### Run Git Commands
81
82
82
83
``` python
83
84
import pathlib
@@ -87,10 +88,15 @@ git = Git(path=pathlib.Path.cwd() / 'my_git_repo')
87
88
git.clone(url = ' https://github.com/vcs-python/libvcs.git' )
88
89
```
89
90
90
- ## Sync
91
+ Above: [ ` libvcs.cmd.git.Git ` ] ( https://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git ) using
92
+ [ ` Git.clone() ` ] ( http://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git.clone ) .
93
+
94
+ ## Repository Synchronization
91
95
92
- Create a [ ` GitSync ` ] ( https://libvcs.git-pull.com/projects/git.html#libvcs.sync.git.GitProject )
93
- object of the project to inspect / checkout / update:
96
+ Synchronize your repositories using the
97
+ [ ` libvcs.sync ` ] ( https://libvcs.git-pull.com/sync/ ) module.
98
+
99
+ ### Clone and Update Repositories
94
100
95
101
``` python
96
102
import pathlib
@@ -112,25 +118,29 @@ repo = GitSync(
112
118
u ' 5c227e6ab4aab44bf097da2e088b0ff947370ab8'
113
119
```
114
120
115
- ## Pytest plugin
121
+ Above: [ ` libvcs.sync.git.GitSync ` ] ( https://libvcs.git-pull.com/projects/git.html#libvcs.sync.git.GitSync ) repository
122
+ object using
123
+ [ ` GitSync.update_repo() ` ] ( https://libvcs.git-pull.com/sync/git.html#libvcs.sync.git.GitSync.update_repo )
124
+ and
125
+ [ ` GitSync.get_revision() ` ] ( https://libvcs.git-pull.com/sync/git.html#libvcs.sync.git.GitSync.get_revision ) .
116
126
117
- libvcs also provides a test rig for local repositories. It automatically can provide clean local
118
- repositories and working copies for git, svn, and mercurial. They are automatically cleaned up after
119
- each test.
127
+ ## Pytest plugin: Temporary VCS repositories for testing
120
128
121
- It works by bootstrapping a temporary ` $HOME ` environment in a
122
- [ ` TmpPathFactory ` ] ( https://docs.pytest.org/en/7.1.x/reference/reference.html#tmp-path-factory-factory-api )
123
- for automatic cleanup.
129
+ libvcs [ pytest plugin] ( https://libvcs.git-pull.com/pytest-plugin.html ) provides [ py.test fixtures] to swiftly create local VCS repositories and working repositories to test with. Repositories are automatically cleaned on test teardown.
130
+
131
+ [ py.test fixtures ] : https://docs.pytest.org/en/8.2.x/explanation/fixtures.html
132
+
133
+ ### Use temporary, local VCS in py.test
124
134
125
135
``` python
126
136
import pathlib
127
137
128
- from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
138
+ from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
129
139
from libvcs.sync.git import GitSync
130
140
131
141
132
142
def test_repo_git_remote_checkout (
133
- create_git_remote_repo : CreateProjectCallbackFixtureProtocol ,
143
+ create_git_remote_repo : CreateRepoPytestFixtureFn ,
134
144
tmp_path : pathlib.Path,
135
145
projects_path : pathlib.Path,
136
146
) -> None :
@@ -147,7 +157,9 @@ def test_repo_git_remote_checkout(
147
157
assert pathlib.Path(git_repo_checkout_dir / " .git" ).exists()
148
158
```
149
159
150
- Learn more on the docs at https://libvcs.git-pull.com/pytest-plugin.html
160
+ Under the hood: fixtures bootstrap a temporary ` $HOME ` environment in a
161
+ [ ` TmpPathFactory ` ] ( https://docs.pytest.org/en/7.1.x/reference/reference.html#tmp-path-factory-factory-api )
162
+ for automatic cleanup and ` pytest-xdist ` compatibility..
151
163
152
164
## Donations
153
165
0 commit comments