Skip to content

Commit 5543321

Browse files
committed
docs(cmd/git): add prose introductions to subcommand pages
why: Make Manager/Cmd pattern usage clear at a glance what: - Add Overview section with pattern explanation to all 8 pages - Include practical code examples for each subcommand - Reference git man pages (e.g., git-branch(1)) - Note legacy interfaces where applicable (stash, submodule)
1 parent c5193ed commit 5543321

8 files changed

Lines changed: 242 additions & 0 deletions

File tree

docs/cmd/git/branch.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
For `git-branch(1)`.
44

5+
## Overview
6+
7+
Manage git branches using {class}`~libvcs.cmd.git.GitBranchManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitBranchCmd` (per-branch operations).
9+
10+
### Example
11+
12+
```python
13+
from libvcs.cmd.git import Git
14+
15+
git = Git(path='/path/to/repo')
16+
17+
# List all branches
18+
branches = git.branches.ls()
19+
20+
# List remote branches only
21+
remote_branches = git.branches.ls(remotes=True)
22+
23+
# Create a new branch
24+
git.branches.create('feature-branch')
25+
26+
# Get a specific branch and operate on it
27+
branch = git.branches.get(branch_name='feature-branch')
28+
branch.rename('new-feature')
29+
branch.delete()
30+
```
31+
32+
## API Reference
33+
534
```{eval-rst}
635
.. autoclass:: libvcs.cmd.git.GitBranchManager
736
:members:

docs/cmd/git/notes.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22

33
For `git-notes(1)`.
44

5+
## Overview
6+
7+
Manage git notes using {class}`~libvcs.cmd.git.GitNotesManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitNoteCmd` (per-note operations).
9+
10+
### Example
11+
12+
```python
13+
from libvcs.cmd.git import Git
14+
15+
git = Git(path='/path/to/repo')
16+
17+
# Add a note to a commit
18+
git.notes.add(object='HEAD', message='This is a note')
19+
20+
# List all notes
21+
notes = git.notes.ls()
22+
23+
# Get a specific note and operate on it
24+
note = git.notes.get(object='HEAD')
25+
note.show()
26+
note.append(message='Additional info')
27+
note.remove()
28+
29+
# Prune notes for non-existent objects
30+
git.notes.prune()
31+
```
32+
33+
## API Reference
34+
535
```{eval-rst}
636
.. autoclass:: libvcs.cmd.git.GitNotesManager
737
:members:

docs/cmd/git/reflog.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
For `git-reflog(1)`.
44

5+
## Overview
6+
7+
Manage git reflog using {class}`~libvcs.cmd.git.GitReflogManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitReflogEntryCmd` (per-entry operations).
9+
10+
### Example
11+
12+
```python
13+
from libvcs.cmd.git import Git
14+
15+
git = Git(path='/path/to/repo')
16+
17+
# List reflog entries
18+
entries = git.reflog.ls()
19+
20+
# List entries for a specific ref
21+
head_entries = git.reflog.ls(ref='HEAD')
22+
23+
# Check if reflog exists for a ref
24+
git.reflog.exists(ref='main')
25+
26+
# Expire old reflog entries
27+
git.reflog.expire(ref='HEAD', expire='90.days.ago')
28+
```
29+
30+
## API Reference
31+
532
```{eval-rst}
633
.. autoclass:: libvcs.cmd.git.GitReflogManager
734
:members:

docs/cmd/git/remote.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
For `git-remote(1)`.
44

5+
## Overview
6+
7+
Manage git remotes using {class}`~libvcs.cmd.git.GitRemoteManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitRemoteCmd` (per-remote operations).
9+
10+
### Example
11+
12+
```python
13+
from libvcs.cmd.git import Git
14+
15+
git = Git(path='/path/to/repo')
16+
17+
# List all remotes
18+
remotes = git.remotes.ls()
19+
20+
# Add a new remote
21+
git.remotes.add(name='upstream', url='https://github.com/org/repo.git')
22+
23+
# Get a specific remote and operate on it
24+
origin = git.remotes.get(remote_name='origin')
25+
origin.show()
26+
origin.prune()
27+
origin.set_url('https://new-url.git')
28+
```
29+
30+
## API Reference
31+
532
```{eval-rst}
633
.. autoclass:: libvcs.cmd.git.GitRemoteManager
734
:members:

docs/cmd/git/stash.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22

33
For `git-stash(1)`.
44

5+
## Overview
6+
7+
Manage git stashes using {class}`~libvcs.cmd.git.GitStashManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitStashEntryCmd` (per-stash operations).
9+
10+
:::{note}
11+
{class}`~libvcs.cmd.git.GitStashCmd` is the legacy interface. Use `git.stashes`
12+
({class}`~libvcs.cmd.git.GitStashManager`) for the new Manager/Cmd pattern.
13+
:::
14+
15+
### Example
16+
17+
```python
18+
from libvcs.cmd.git import Git
19+
20+
git = Git(path='/path/to/repo')
21+
22+
# Push changes to stash
23+
git.stashes.push(message='Work in progress')
24+
25+
# List all stashes
26+
stashes = git.stashes.ls()
27+
28+
# Get a specific stash and operate on it
29+
stash = git.stashes.get(index=0)
30+
stash.show()
31+
stash.apply()
32+
stash.drop()
33+
34+
# Clear all stashes
35+
git.stashes.clear()
36+
```
37+
38+
## API Reference
39+
540
```{eval-rst}
641
.. autoclass:: libvcs.cmd.git.GitStashManager
742
:members:

docs/cmd/git/submodule.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22

33
For `git-submodule(1)`.
44

5+
## Overview
6+
7+
Manage git submodules using {class}`~libvcs.cmd.git.GitSubmoduleManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitSubmoduleEntryCmd` (per-submodule operations).
9+
10+
:::{note}
11+
{class}`~libvcs.cmd.git.GitSubmoduleCmd` is the legacy interface. Use `git.submodules`
12+
({class}`~libvcs.cmd.git.GitSubmoduleManager`) for the new Manager/Cmd pattern.
13+
:::
14+
15+
### Example
16+
17+
```python
18+
from libvcs.cmd.git import Git
19+
20+
git = Git(path='/path/to/repo')
21+
22+
# Add a submodule
23+
git.submodules.add(url='https://github.com/org/lib.git', path='vendor/lib')
24+
25+
# List all submodules
26+
submodules = git.submodules.ls()
27+
28+
# Get a specific submodule and operate on it
29+
submodule = git.submodules.get(path='vendor/lib')
30+
submodule.init()
31+
submodule.update()
32+
submodule.deinit()
33+
34+
# Sync submodule URLs
35+
git.submodules.sync()
36+
```
37+
38+
## API Reference
39+
540
```{eval-rst}
641
.. autoclass:: libvcs.cmd.git.GitSubmoduleManager
742
:members:

docs/cmd/git/tag.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
For `git-tag(1)`.
44

5+
## Overview
6+
7+
Manage git tags using {class}`~libvcs.cmd.git.GitTagManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitTagCmd` (per-tag operations).
9+
10+
### Example
11+
12+
```python
13+
from libvcs.cmd.git import Git
14+
15+
git = Git(path='/path/to/repo')
16+
17+
# Create a tag
18+
git.tags.create(name='v1.0.0', message='Release 1.0.0')
19+
20+
# List all tags
21+
tags = git.tags.ls()
22+
23+
# Filter tags
24+
release_tags = git.tags.ls(pattern='v*')
25+
26+
# Get a specific tag and operate on it
27+
tag = git.tags.get(tag_name='v1.0.0')
28+
tag.show()
29+
tag.delete()
30+
```
31+
32+
## API Reference
33+
534
```{eval-rst}
635
.. autoclass:: libvcs.cmd.git.GitTagManager
736
:members:

docs/cmd/git/worktree.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22

33
For `git-worktree(1)`.
44

5+
## Overview
6+
7+
Manage git worktrees using {class}`~libvcs.cmd.git.GitWorktreeManager` (collection-level)
8+
and {class}`~libvcs.cmd.git.GitWorktreeCmd` (per-worktree operations).
9+
10+
### Example
11+
12+
```python
13+
from libvcs.cmd.git import Git
14+
15+
git = Git(path='/path/to/repo')
16+
17+
# List all worktrees
18+
worktrees = git.worktrees.ls()
19+
20+
# Add a new worktree
21+
git.worktrees.add(path='/path/to/worktree', branch='feature-branch')
22+
23+
# Get a specific worktree and operate on it
24+
wt = git.worktrees.get(worktree_path='/path/to/worktree')
25+
wt.lock(reason='Do not delete')
26+
wt.unlock()
27+
wt.remove()
28+
29+
# Prune stale worktrees
30+
git.worktrees.prune()
31+
```
32+
33+
## API Reference
34+
535
```{eval-rst}
636
.. autoclass:: libvcs.cmd.git.GitWorktreeManager
737
:members:

0 commit comments

Comments
 (0)