Skip to content

Commit c88f376

Browse files
authored
tests(git[sync]),docs: Improve git cmd docs, git sync tests (#432)
2 parents 9c28c98 + 2db82e8 commit c88f376

File tree

8 files changed

+167
-104
lines changed

8 files changed

+167
-104
lines changed

docs/cmd/git.md renamed to docs/cmd/git/index.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22

33
For `git(1)`.
44

5-
Compare to: [`fabtools.git`](https://fabtools.readthedocs.io/en/0.19.0/api/git.html#git-module),
5+
_Compare to: [`fabtools.git`](https://fabtools.readthedocs.io/en/0.19.0/api/git.html#git-module),
66
[`salt.modules.git`](https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.git.html),
7-
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)
7+
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)_
8+
9+
```{toctree}
10+
:caption: Subcommands
11+
:maxdepth: 1
12+
13+
submodule
14+
remote
15+
stash
16+
```
817

918
```{eval-rst}
1019
.. automodule:: libvcs.cmd.git
1120
:members:
1221
:show-inheritance:
1322
:undoc-members:
23+
:exclude-members: GitSubmoduleCmd,
24+
GitRemoteCmd,
25+
GitStashCmd
1426
```

docs/cmd/git/remote.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `remote`
2+
3+
For `git-remote(1)`.
4+
5+
```{eval-rst}
6+
.. autoclass:: libvcs.cmd.git.GitRemoteCmd
7+
:members:
8+
:show-inheritance:
9+
:undoc-members:
10+
```

docs/cmd/git/stash.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `stash`
2+
3+
For `git-stash(1)`.
4+
5+
```{eval-rst}
6+
.. autoclass:: libvcs.cmd.git.GitStashCmd
7+
:members:
8+
:show-inheritance:
9+
:undoc-members:
10+
```

docs/cmd/git/submodule.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `submodule`
2+
3+
For `git-submodule(1)`.
4+
5+
```{eval-rst}
6+
.. autoclass:: libvcs.cmd.git.GitSubmoduleCmd
7+
:members:
8+
:show-inheritance:
9+
:undoc-members:
10+
```

docs/cmd/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ versions.
1616
```{toctree}
1717
:caption: API
1818
19-
git
19+
git/index
2020
hg
2121
svn
2222
```

docs/redirects.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@
2020
"projects/git.md" "sync/git.md"
2121
"projects/hg.md" "sync/hg.md"
2222
"projects/svn.md" "sync/svn.md"
23+
"cmd/git.md" "cmd/git/index.md"

src/libvcs/cmd/git.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(
2424
dir: StrPath,
2525
progress_callback: Optional[ProgressCallbackProtocol] = None,
2626
) -> None:
27-
"""Lite, typed, pythonic wrapper for git(1).
27+
r"""Lite, typed, pythonic wrapper for git(1).
2828
2929
Parameters
3030
----------
@@ -33,8 +33,28 @@ def __init__(
3333
3434
Examples
3535
--------
36-
>>> Git(dir=tmp_path)
36+
>>> git = Git(dir=git_local_clone.dir)
37+
>>> git
3738
<Git dir=...>
39+
40+
Subcommands:
41+
42+
>>> git.remote.show()
43+
'origin'
44+
45+
>>> git.remote.add(
46+
... name='my_remote', url=f'file:///dev/null'
47+
... )
48+
''
49+
50+
>>> git.remote.show()
51+
'my_remote\norigin'
52+
53+
>>> git.stash.save(message="Message")
54+
'No local changes to save'
55+
56+
>>> git.submodule.init()
57+
''
3858
"""
3959
#: Directory to check out
4060
self.dir: pathlib.Path
@@ -2370,7 +2390,7 @@ def run(
23702390
check_returncode: Optional[bool] = None,
23712391
**kwargs: Any,
23722392
) -> str:
2373-
r"""Wraps `git submodule <https://git-scm.com/docs/git-remote>`_.
2393+
r"""Wraps `git remote <https://git-scm.com/docs/git-remote>`_.
23742394
23752395
Examples
23762396
--------
@@ -2405,7 +2425,7 @@ def add(
24052425
log_in_real_time: bool = False,
24062426
check_returncode: Optional[bool] = None,
24072427
) -> str:
2408-
"""git submodule add
2428+
"""git remote add
24092429
24102430
Examples
24112431
--------
@@ -2441,7 +2461,7 @@ def rename(
24412461
log_in_real_time: bool = False,
24422462
check_returncode: Optional[bool] = None,
24432463
) -> str:
2444-
"""git submodule rename
2464+
"""git remote rename
24452465
24462466
Examples
24472467
--------
@@ -2474,7 +2494,7 @@ def remove(
24742494
log_in_real_time: bool = False,
24752495
check_returncode: Optional[bool] = None,
24762496
) -> str:
2477-
"""git submodule remove
2497+
"""git remote remove
24782498
24792499
Examples
24802500
--------
@@ -2503,7 +2523,7 @@ def show(
25032523
log_in_real_time: bool = False,
25042524
check_returncode: Optional[bool] = None,
25052525
) -> str:
2506-
"""git submodule show
2526+
"""git remote show
25072527
25082528
Examples
25092529
--------
@@ -2538,7 +2558,7 @@ def prune(
25382558
log_in_real_time: bool = False,
25392559
check_returncode: Optional[bool] = None,
25402560
) -> str:
2541-
"""git submodule prune
2561+
"""git remote prune
25422562
25432563
Examples
25442564
--------
@@ -2572,7 +2592,7 @@ def get_url(
25722592
log_in_real_time: bool = False,
25732593
check_returncode: Optional[bool] = None,
25742594
) -> str:
2575-
"""git submodule get-url
2595+
"""git remote get-url
25762596
25772597
Examples
25782598
--------
@@ -2614,7 +2634,7 @@ def set_url(
26142634
log_in_real_time: bool = False,
26152635
check_returncode: Optional[bool] = None,
26162636
) -> str:
2617-
"""git submodule set-url
2637+
"""git remote set-url
26182638
26192639
Examples
26202640
--------

0 commit comments

Comments
 (0)