Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d10fbcc
cmd(git) Git.branches (including management query)
tony Jun 18, 2024
cabe3b7
py(git[cmd]) Add `GitRemoteManager` to `Git.remotes`
tony Jul 4, 2024
602f709
feat(git): enhance git init support with all options and tests
tony Feb 22, 2025
88b4c80
docs: improve Git.init documentation and validation tests
tony Feb 22, 2025
774807b
feat: add parameter validation for git init
tony Feb 22, 2025
f429f58
feat: enhance Git.init with ref-format and improved validation
tony Feb 22, 2025
57b3176
docs(notes): add git command support audit 2025-11-26
tony Nov 26, 2025
8aa822a
docs(notes): add CLI flag → Python parameter mappings
tony Nov 26, 2025
339f60e
cmd/git(feat[GitBranchCmd]): add delete, rename, copy, upstream methods
tony Nov 26, 2025
230620a
tests/cmd(test[GitBranch]): add tests for branch operations
tony Nov 26, 2025
da514c1
cmd/git(feat[GitRemoteCmd]): add set_branches, set_head, update methods
tony Nov 26, 2025
49b58bb
tests/cmd(test[GitRemote]): add tests for remote operations
tony Nov 26, 2025
5938c07
cmd/git(feat[GitTag]): add GitTagManager and GitTagCmd classes
tony Nov 26, 2025
9a9d789
tests/cmd(test[GitTag]): add tests for tag operations
tony Nov 26, 2025
e34d1cc
cmd/git(feat[GitStash]): add GitStashManager and GitStashEntryCmd cla…
tony Nov 26, 2025
e957724
tests/cmd(test[GitStash]): add tests for stash operations
tony Nov 26, 2025
be0b288
cmd/git(feat[GitWorktreeManager]): add GitWorktreeManager and GitWork…
tony Nov 26, 2025
9b10216
tests/cmd(test[GitWorktree]): add tests for worktree operations
tony Nov 26, 2025
58616d7
cmd/git(feat[GitNotesManager]): add GitNotesManager and GitNoteCmd cl…
tony Nov 26, 2025
d2ea41b
tests/cmd(test[GitNotes]): add tests for notes operations
tony Nov 26, 2025
a035a31
cmd/git(feat[GitReflogManager]): add GitReflogManager and GitReflogEn…
tony Nov 26, 2025
ac339e0
tests/cmd(test[GitReflog]): add tests for reflog operations
tony Nov 26, 2025
5870c78
cmd/git(feat[GitSubmoduleManager]): add GitSubmoduleManager and GitSu…
tony Nov 26, 2025
61e94fd
tests/cmd(test[GitSubmodule]): add tests for submodule operations
tony Nov 26, 2025
7f3886c
cmd/git(fix[GitNoteCmd]): fix hanging doctest and pass kwargs through…
tony Nov 26, 2025
d2bd99a
tests/cmd(style[GitStash]): use ternary for apply/pop
tony Nov 26, 2025
5c634f0
cmd/git(fix[GitSubmoduleManager.add]): use local file URL in doctest
tony Nov 26, 2025
8314119
tests/cmd(fix[GitRemote]): handle unchanged HEAD in set_head test
tony Nov 26, 2025
a8210f3
cmd/git(docs[GitStashCmd.push]): complete docstring
tony Nov 27, 2025
2dfd3e1
cmd/git(feat[GitBranch]): add track() and enhance ls() with filters
tony Nov 27, 2025
bb3215e
tests/cmd(test[GitBranch]): add tests for track() and ls() filters
tony Nov 27, 2025
8cf1b24
cmd/git(docs[GitTag]): make doctests self-contained with ellipsis
tony Nov 27, 2025
152d77f
cmd/git(feat[GitBranchManager.ls]): add verbose parameter
tony Nov 27, 2025
8bfb54b
tests/cmd(test[GitBranch]): add test for verbose parameter
tony Nov 27, 2025
4bddbc9
tests/cmd(test[GitCmd]): add tests for untested methods
tony Nov 27, 2025
d0cfa3d
docs(notes): update command support status to Implemented
tony Nov 27, 2025
4506758
docs(cmd/git): add documentation for new Manager/Cmd classes
tony Nov 27, 2025
7f6ea9b
docs(CHANGES): add changelog for Manager/Cmd pattern (#465)
tony Nov 27, 2025
5acef2b
docs(cmd/git): add Manager/Cmd pattern introduction
tony Nov 28, 2025
8e9c17e
docs(README): add Manager/Cmd pattern examples
tony Nov 28, 2025
39a38a9
docs(quickstart): add basic usage section
tony Nov 28, 2025
c5193ed
docs(cmd): add module overview
tony Nov 28, 2025
5543321
docs(cmd/git): add prose introductions to subcommand pages
tony Nov 28, 2025
239c790
docs(internals/query_list): add usage context and lookup reference
tony Nov 28, 2025
516520c
cmd/git(fix[show]): Fix incorrect boolean condition for no_query_remotes
tony Nov 30, 2025
1951dc1
tests/cmd/git(test[show]): Add tests for no_query_remotes parameter
tony Nov 30, 2025
62c48c6
cmd/git(fix[Git]): Align class annotations with instance variable names
tony Nov 30, 2025
4b8a0f7
cmd/git(fix[create]): Use git branch instead of checkout -b for branc…
tony Nov 30, 2025
e45f18c
cmd/git(fix[branch.run]): Remove broken command parameter
tony Nov 30, 2025
4d2d4f8
cmd/git(fix[run]): Remove invalid cached parameter from branch and stash
tony Nov 30, 2025
12065f6
cmd/git(fix[stash.pop]): Use stash@{N} format instead of pathspec sep…
tony Nov 30, 2025
46e9c1f
tests/cmd/git(test): Add tests for branch create checkout parameter
tony Nov 30, 2025
a6245ae
tests/cmd/git(test): Add test for stash pop with specific index
tony Nov 30, 2025
03b124c
cmd/git(fix[init]): Don't pass --shared when shared=False
tony Nov 30, 2025
ece0d80
cmd/git(fix[stash.push]): Handle str paths in GitStashCmd.push
tony Nov 30, 2025
5c00880
cmd/git(fix[remote.add]): Wire fetch, track, and master parameters
tony Nov 30, 2025
2076352
cmd/git(test[Git.init]): Add test for shared parameter boolean behavior
tony Nov 30, 2025
8a95658
cmd/git(test[GitStashCmd.push]): Add test for path parameter types
tony Nov 30, 2025
911dd2c
cmd/git(test[GitRemoteManager.add]): Add test for fetch/track/master …
tony Nov 30, 2025
f8f4d9b
cmd/git(fix[GitNotesManager.merge]): Handle commit/abort forms correctly
tony Nov 30, 2025
7cf3f46
cmd/git(fix[run methods]): Forward **kwargs to underlying cmd.run calls
tony Nov 30, 2025
ea59519
cmd/git(fix[GitRemoteManager.add]): Validate mirror parameter correctly
tony Nov 30, 2025
79a5fe8
cmd/git(fix[GitRemoteManager]): Fix invalid doctest using quiet param…
tony Nov 30, 2025
ca7a3b7
cmd/git(fix[Git.run]): Iterate -C paths instead of appending list
tony Nov 30, 2025
d4babb9
cmd/git(fix[Git.run]): Fix boolean config serialization typo
tony Nov 30, 2025
9907486
cmd/git(fix[Git.init]): Remove invalid --default parameter
tony Nov 30, 2025
4f4e12a
cmd/git(fix[remote show]): Only add --verbose when explicitly True
tony Nov 30, 2025
3a6153f
cmd/git(fix[Git.run]): Implement config_env parameter
tony Nov 30, 2025
7644c2b
cmd/git(fix[Git.clone]): Fix separate_git_dir repr quoting issue
tony Nov 30, 2025
9eec47c
cmd/git(fix[Git.clone]): Fix reference_if_able flag name
tony Nov 30, 2025
5707ec6
cmd/git(fix[Git.fetch,Git.pull]): Remove clone-only branch/origin params
tony Nov 30, 2025
ff51b4f
cmd/git(fix[Git.fetch,Git.pull]): Implement missing fetch parameters
tony Nov 30, 2025
47e6819
cmd/git(fix[Git.rebase]): Fix whitespace options
tony Nov 30, 2025
0904501
cmd/git(fix[Git.rebase]): Fix --no-rerere-autoupdate typo
tony Nov 30, 2025
1b18d7a
cmd/git(fix[Git.pull]): Fix --signoff flag spelling
tony Nov 30, 2025
eda818c
cmd/git(fix[GitNoteCmd]): Propagate custom ref to note commands
tony Nov 30, 2025
cb42d4a
cmd/git(fix[GitRemoteManager.ls]): Handle URLs with spaces
tony Nov 30, 2025
9421936
tests/cmd(test_git): Add functional tests for recent bug fixes
tony Nov 30, 2025
a402e4d
cmd/git(fix): Forward **kwargs in remaining Manager/Cmd run() methods
tony Nov 30, 2025
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
53 changes: 53 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,59 @@ $ uv add libvcs --prerelease allow

_Upcoming changes will be written here._

### New features

#### cmd: Manager/Cmd pattern for git subcommands (#465)

New architecture for git subcommands that returns typed objects instead of raw strings:

- **Manager classes** handle collection-level operations (`ls()`, `get()`, `filter()`, `add()`/`create()`)
- **Cmd classes** handle per-entity operations (`show()`, `remove()`, `rename()`)
- All `ls()` methods return `QueryList` for chainable filtering

New subcommand managers accessible via `Git` instance:

- {attr}`Git.branches <libvcs.cmd.git.Git.branches>` -> {class}`~libvcs.cmd.git.GitBranchManager`
- {attr}`Git.remotes <libvcs.cmd.git.Git.remotes>` -> {class}`~libvcs.cmd.git.GitRemoteManager`
- {attr}`Git.stashes <libvcs.cmd.git.Git.stashes>` -> {class}`~libvcs.cmd.git.GitStashManager`
- {attr}`Git.tags <libvcs.cmd.git.Git.tags>` -> {class}`~libvcs.cmd.git.GitTagManager`
- {attr}`Git.worktrees <libvcs.cmd.git.Git.worktrees>` -> {class}`~libvcs.cmd.git.GitWorktreeManager`
- {attr}`Git.notes <libvcs.cmd.git.Git.notes>` -> {class}`~libvcs.cmd.git.GitNotesManager`
- {attr}`Git.submodules <libvcs.cmd.git.Git.submodules>` -> {class}`~libvcs.cmd.git.GitSubmoduleManager`
- {attr}`Git.reflog <libvcs.cmd.git.Git.reflog>` -> {class}`~libvcs.cmd.git.GitReflogManager`

Example usage:

```python
git = Git(path="/path/to/repo")

# List all branches, filter remote ones
remote_branches = git.branches.ls(remotes=True)

# Get a specific tag
tag = git.tags.get(tag_name="v1.0.0")
tag.delete()

# Create a new branch and switch to it
git.branches.create("feature-branch")
```

#### cmd: Enhanced Git.init() (#465)

- Added `ref_format` parameter for `--ref-format` (files/reftable)
- Added `make_parents` parameter to auto-create parent directories
- Improved parameter validation with clear error messages
- Extended `shared` parameter to support octal permissions (e.g., "0660")

### Documentation

- Add API documentation for all new Manager/Cmd classes (#465)
- Split git subcommand documentation into separate pages: branch, tag, worktree, notes, reflog

### Tests

- Comprehensive test coverage for all new Manager/Cmd classes (#465)

## libvcs 0.37.0 (2025-11-01)

### Breaking changes
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ git.clone(url='https://github.com/vcs-python/libvcs.git')
Above: [`libvcs.cmd.git.Git`](https://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git) using
[`Git.clone()`](http://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git.clone).

### Manage Branches, Tags, and More

Work with git subcommands using typed Python objects:

```python
from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# Branches
branches = git.branches.ls() # List all branches
git.branches.create('feature-branch') # Create a branch

# Tags
git.tags.create(name='v1.0.0', message='Release')
tags = git.tags.ls()

# Remotes
remotes = git.remotes.ls()
remote = git.remotes.get(remote_name='origin')
remote.prune()
```

See the [Manager/Cmd pattern documentation](https://libvcs.git-pull.com/cmd/git/index.html) for more.

## Repository Synchronization

Synchronize your repositories using the
Expand Down
44 changes: 44 additions & 0 deletions docs/cmd/git/branch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# `branch`

For `git-branch(1)`.

## Overview

Manage git branches using {class}`~libvcs.cmd.git.GitBranchManager` (collection-level)
and {class}`~libvcs.cmd.git.GitBranchCmd` (per-branch operations).

### Example

```python
from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# List all branches
branches = git.branches.ls()

# List remote branches only
remote_branches = git.branches.ls(remotes=True)

# Create a new branch
git.branches.create('feature-branch')

# Get a specific branch and operate on it
branch = git.branches.get(branch_name='feature-branch')
branch.rename('new-feature')
branch.delete()
```

## API Reference

```{eval-rst}
.. autoclass:: libvcs.cmd.git.GitBranchManager
:members:
:show-inheritance:
:undoc-members:

.. autoclass:: libvcs.cmd.git.GitBranchCmd
:members:
:show-inheritance:
:undoc-members:
```
69 changes: 68 additions & 1 deletion docs/cmd/git/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,63 @@ _Compare to: [`fabtools.git`](https://fabtools.readthedocs.io/en/0.19.0/api/git.
[`salt.modules.git`](https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.git.html),
[`ansible.builtin.git`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html)_

## Manager/Cmd Pattern

libvcs provides a **Manager/Cmd pattern** for git subcommands:

- **Manager** classes (`git.branches`, `git.tags`, etc.) handle collection-level operations
- **Cmd** classes represent individual entities with mutation methods

```
Git instance
├── branches: GitBranchManager
│ ├── ls() -> QueryList[GitBranchCmd]
│ ├── get() -> GitBranchCmd
│ └── create()
├── tags: GitTagManager
├── remotes: GitRemoteManager
├── stashes: GitStashManager
├── worktrees: GitWorktreeManager
├── notes: GitNotesManager
├── submodules: GitSubmoduleManager
└── reflog: GitReflogManager
```

### Quick Example

```python
from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# List all branches
branches = git.branches.ls()

# Filter to remote branches only
remote_branches = git.branches.ls(remotes=True)

# Get a specific branch and rename it
branch = git.branches.get(branch_name='old-name')
branch.rename('new-name')

# Create and manage tags
git.tags.create(name='v1.0.0', message='Release 1.0')
tag = git.tags.get(tag_name='v1.0.0')
tag.delete()
```

```{toctree}
:caption: Subcommands
:maxdepth: 1

submodule
remote
stash
branch
tag
worktree
notes
reflog
```

```{eval-rst}
Expand All @@ -21,6 +71,23 @@ stash
:show-inheritance:
:undoc-members:
:exclude-members: GitSubmoduleCmd,
GitSubmoduleManager,
GitSubmodule,
GitSubmoduleEntryCmd,
GitRemoteCmd,
GitStashCmd
GitRemoteManager,
GitStashCmd,
GitStashManager,
GitStashEntryCmd,
GitBranchCmd,
GitBranchManager,
GitTagCmd,
GitTagManager,
GitWorktreeCmd,
GitWorktreeManager,
GitNoteCmd,
GitNotesManager,
GitReflogEntry,
GitReflogEntryCmd,
GitReflogManager
```
45 changes: 45 additions & 0 deletions docs/cmd/git/notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# `notes`

For `git-notes(1)`.

## Overview

Manage git notes using {class}`~libvcs.cmd.git.GitNotesManager` (collection-level)
and {class}`~libvcs.cmd.git.GitNoteCmd` (per-note operations).

### Example

```python
from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# Add a note to a commit
git.notes.add(object='HEAD', message='This is a note')

# List all notes
notes = git.notes.ls()

# Get a specific note and operate on it
note = git.notes.get(object='HEAD')
note.show()
note.append(message='Additional info')
note.remove()

# Prune notes for non-existent objects
git.notes.prune()
```

## API Reference

```{eval-rst}
.. autoclass:: libvcs.cmd.git.GitNotesManager
:members:
:show-inheritance:
:undoc-members:

.. autoclass:: libvcs.cmd.git.GitNoteCmd
:members:
:show-inheritance:
:undoc-members:
```
47 changes: 47 additions & 0 deletions docs/cmd/git/reflog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# `reflog`

For `git-reflog(1)`.

## Overview

Manage git reflog using {class}`~libvcs.cmd.git.GitReflogManager` (collection-level)
and {class}`~libvcs.cmd.git.GitReflogEntryCmd` (per-entry operations).

### Example

```python
from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# List reflog entries
entries = git.reflog.ls()

# List entries for a specific ref
head_entries = git.reflog.ls(ref='HEAD')

# Check if reflog exists for a ref
git.reflog.exists(ref='main')

# Expire old reflog entries
git.reflog.expire(ref='HEAD', expire='90.days.ago')
```

## API Reference

```{eval-rst}
.. autoclass:: libvcs.cmd.git.GitReflogManager
:members:
:show-inheritance:
:undoc-members:

.. autoclass:: libvcs.cmd.git.GitReflogEntryCmd
:members:
:show-inheritance:
:undoc-members:

.. autoclass:: libvcs.cmd.git.GitReflogEntry
:members:
:show-inheritance:
:undoc-members:
```
32 changes: 32 additions & 0 deletions docs/cmd/git/remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,39 @@

For `git-remote(1)`.

## Overview

Manage git remotes using {class}`~libvcs.cmd.git.GitRemoteManager` (collection-level)
and {class}`~libvcs.cmd.git.GitRemoteCmd` (per-remote operations).

### Example

```python
from libvcs.cmd.git import Git

git = Git(path='/path/to/repo')

# List all remotes
remotes = git.remotes.ls()

# Add a new remote
git.remotes.add(name='upstream', url='https://github.com/org/repo.git')

# Get a specific remote and operate on it
origin = git.remotes.get(remote_name='origin')
origin.show()
origin.prune()
origin.set_url('https://new-url.git')
```

## API Reference

```{eval-rst}
.. autoclass:: libvcs.cmd.git.GitRemoteManager
:members:
:show-inheritance:
:undoc-members:

.. autoclass:: libvcs.cmd.git.GitRemoteCmd
:members:
:show-inheritance:
Expand Down
Loading