-
Notifications
You must be signed in to change notification settings - Fork 11
cmd(git): More commands #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tony
wants to merge
44
commits into
master
Choose a base branch
from
more-git-cmds
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #465 +/- ##
==========================================
+ Coverage 42.90% 51.77% +8.86%
==========================================
Files 38 38
Lines 3627 5451 +1824
Branches 794 1037 +243
==========================================
+ Hits 1556 2822 +1266
- Misses 1718 2104 +386
- Partials 353 525 +172 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ff046f3 to
5dff81e
Compare
8808231 to
700a4fa
Compare
f520132 to
af58b49
Compare
adfbeaa to
76822c5
Compare
8adff4c to
c843022
Compare
8839c2a to
0385215
Compare
11dbd6a to
8578585
Compare
2e5347d to
bb6d40e
Compare
…tryCmd classes why: Enable reflog management with Manager/Cmd pattern for consistency what: - Add GitReflogEntry dataclass for structured reflog data - Add GitReflogEntryCmd for per-entry operations (show, delete) - Add GitReflogManager for collection operations (show, expire, exists) - Support QueryList-based filtering with ls(), get(), filter() methods - Parse `git reflog show` output into GitReflogEntry objects - Add self.reflog to Git class for easy access via git.reflog - Include comprehensive doctests for all methods
why: Ensure GitReflogManager and GitReflogEntryCmd work correctly what: - Add ReflogShowFixture with parametrized tests for show operation - Add tests for ls, get, filter, exists, expire operations - Add test for GitReflogEntryCmd.show via entry.cmd - All 8 tests verify core reflog functionality
…bmoduleEntryCmd why: Complete the Manager/Cmd pattern for submodule operations what: - Add GitSubmodule dataclass with name, path, url, sha, branch, status_prefix - Add GitSubmoduleEntryCmd for per-submodule operations: init, update, deinit, set_branch, set_url, status, absorbgitdirs - Add GitSubmoduleManager with collection operations: add, init, update, foreach, sync, summary, absorbgitdirs, _ls, ls, get, filter - Add 'add' to GitSubmoduleCmdCommandLiteral - Add self.submodules to Git class for easy access - Fix return type assertions in get() methods for mypy
why: Validate GitSubmoduleManager and GitSubmoduleEntryCmd functionality what: - Add submodule_repo fixture for creating submodule source repos - Add _setup_submodule_test helper to configure file protocol - Test GitSubmoduleManager methods: add, ls, get, filter, init, update, sync, summary, foreach - Test GitSubmoduleEntryCmd methods: status, init, update - Test GitSubmodule dataclass properties - Test ObjectDoesNotExist raised when submodule not found
… run()
why: The doctest for GitNoteCmd.edit hung because:
1. git notes edit opens an interactive editor
2. GitNoteCmd.run() wasn't passing **kwargs to self.cmd.run()
so config={'core.editor': 'true'} was being dropped
what:
- Use config={'core.editor': 'true'} to override editor via -c flag
- Pass **kwargs through GitNoteCmd.run() to self.cmd.run()
why: Fix ruff SIM108 lint error what: - Convert if/else to ternary operator for stash apply/pop
why: The doctest used https://github.com/example/repo.git which prompts for GitHub credentials, causing the test to hang. what: - Use create_git_remote_repo() fixture with file:// URL - Matches pattern used by GitRemoteManager.add
why: CI failed because git returns "unchanged" when HEAD is already set, but assertion only checked for "set to". what: - Add "unchanged" as valid response in set_head auto assertion
why: The docstring had a TODO placeholder instead of proper documentation. what: - Add proper description for push method - Document path, patch, and staged parameters - Add link to git-stash documentation
why: Complete branch management API per planning docs what: - Add GitBranchCmd.track() to create branches tracking remote refs - Add filter params to GitBranchManager.ls(): _all, remotes, merged, no_merged, contains, sort - Update _ls() to accept local_flags parameter
why: Verify new branch management functionality what: - Add test_branch_track() for GitBranchCmd.track() - Add test_branch_ls_filters() for ls() filter parameters
why: Doctests failed due to state pollution - tags from earlier doctests affected later tests; use ELLIPSIS for cleaner pattern matching what: - GitTagCmd.run: create tag, verify with '...test-tag...' - GitTagManager.__init__: create tag, verify with '...init-doctest-tag...' - GitTagManager.run: create tag, verify with '...run-doctest-tag...'
why: Complete GitBranchManager.ls() filter options to match GitTagManager.ls() what: - Add verbose: bool parameter to ls() method - Add helper function to extract branch name from verbose output - Verbose output format is "name sha1 message" - parse correctly
why: Test the verbose parameter added to GitBranchManager.ls() what: - Verify verbose=True returns branch names correctly - Check that verbose output parsing extracts names properly
why: Complete test coverage for implemented methods lacking unit tests what: - Add test_worktree_move and test_worktree_repair for GitWorktreeCmd - Add test_notes_edit, test_notes_copy, test_notes_merge for GitNoteCmd - Add test_submodule_entry_deinit, test_submodule_entry_set_branch, test_submodule_entry_set_url, test_submodule_entry_absorbgitdirs - Add test_reflog_entry_delete for GitReflogEntryCmd
why: Reflect actual implementation status in planning document what: - Update GitBranchCmd methods (delete, rename, copy, etc.) to Implemented - Update GitBranchManager enhancements to Implemented - Update GitRemoteCmd methods (set_branches, set_head, update) to Implemented - Update all Manager/Cmd classes to Implemented status
why: New git subcommand classes (branch, tag, worktree, notes, reflog) and Manager pattern classes need API documentation for discoverability. what: - Add new doc files: branch.md, tag.md, worktree.md, notes.md, reflog.md - Update remote.md, stash.md, submodule.md to include Manager classes - Update index.md toctree and exclude-members for all 19 new classes
why: Document major new features for the upcoming release. what: - Add Manager/Cmd pattern for git subcommands (branches, remotes, stashes, tags, worktrees, notes, submodules, reflog) - Document enhanced Git.init() with new parameters - Note documentation and test additions
why: Help users understand the new architecture for git subcommands. what: - Add pattern overview with Manager vs Cmd explanation - Add tree diagram showing all available managers - Add quick example showing common operations
why: Showcase the new typed Python API for git subcommands. what: - Add "Manage Branches, Tags, and More" section - Show examples for branches, tags, and remotes - Link to full Manager/Cmd documentation
why: Provide getting-started examples beyond installation. what: - Add Commands section with git init/clone/status examples - Add Subcommand Managers section with branches/tags/remotes - Link to full API reference
why: Help users understand the cmd module and when to use it. what: - Add overview with links to git, hg, svn modules - Add comparison table for cmd vs sync use cases
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)
why: Show how QueryList powers the Manager/Cmd pattern what: - Add overview explaining ls() returns QueryList - Document all available lookup operators - Show filter chaining examples
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Commands (git)
This PR introduces the Manager/Cmd pattern for git subcommands, providing typed Python objects instead of raw strings.
Pattern Overview
Add
GitBranchManager(git.branches) - collection-level branch operationsls()- List branches, returnsQueryList[GitBranchCmd]_all- List all branches (local + remote)remotes- List remote branches onlymerged/no_merged- Filter by merge statuscontains- Branches containing commitverbose- Show tracking infoget(**kwargs)- Get single branch by filterfilter(**kwargs)- Filter branchescheckout(branch)- Checkout a branchcreate(branch)- Create new branch viacheckout -bAdd
GitBranchCmd(git.branches.get(...)) - instance-based mutations of a branchcheckout()-git checkout <branchname>create()-git checkout -b <branchname>delete(force)-git branch -d/-Drename(new_name, force)-git branch -m/-Mcopy(new_name, force)-git branch -c/-Cset_upstream(upstream)-git branch --set-upstream-tounset_upstream()-git branch --unset-upstreamtrack(remote_branch)-git branch -tAdd
GitRemoteManager(git.remotes) - collection-level remote operationsls()- List remotes, returnsQueryList[GitRemoteCmd]get(**kwargs)- Get single remote by filterfilter(**kwargs)- Filter remotesadd(name, url, ...)- Add new remoteshow(name, verbose)- Show remotesEnhance
GitRemoteCmd(git.remotes.get(...)) - instance-based remote operationsrename(new_name, progress)- Rename remoteremove()- Delete remoteshow(verbose, no_query_remotes)- Show remote detailsprune(dry_run)- Prune stale branchesget_url(push, _all)- Get remote URLset_url(url, push, add, delete)- Set remote URLset_branches(*branches, add)- Set tracked branchesset_head(branch, auto, delete)- Set HEAD referenceupdate(prune)- Update remoteAdd
GitStashManager(git.stashes) - collection-level stash operationsls()- List stashes, returnsQueryList[GitStashEntryCmd]get(**kwargs)- Get single stash by filterfilter(**kwargs)- Filter stashespush(message, path, patch, staged, ...)- Push to stashclear()- Clear all stashesAdd
GitStashEntryCmd(git.stashes.get(...)) - instance-based stash operationsshow(stat, patch)- Show stash diffapply(index)- Apply without removingpop(index)- Apply and removedrop()- Delete this stashbranch(branch_name)- Create branch from stashAdd
GitTagManager(git.tags) - collection-level tag operationsls(pattern, sort, contains, merged, ...)- List tags, returnsQueryList[GitTagCmd]get(**kwargs)- Get single tag by filterfilter(**kwargs)- Filter tagscreate(name, ref, message, annotate, sign, force)- Create tagAdd
GitTagCmd(git.tags.get(...)) - instance-based tag operationsshow()- Show tag detailsdelete()- Delete tagverify()- Verify signed tagAdd
GitWorktreeManager(git.worktrees) - collection-level worktree operationsls()- List worktrees, returnsQueryList[GitWorktreeCmd]get(**kwargs)- Get single worktree by filterfilter(**kwargs)- Filter worktreesadd(path, branch, detach, checkout, lock, force)- Add worktreeprune(dry_run, verbose, expire)- Prune worktreesAdd
GitWorktreeCmd(git.worktrees.get(...)) - instance-based worktree operationsremove(force)- Remove worktreelock(reason)- Lock worktreeunlock()- Unlock worktreemove(new_path)- Move worktreerepair()- Repair worktreeAdd
GitNotesManager(git.notes) - collection-level notes operationsls(ref)- List notes, returnsQueryList[GitNoteCmd]get(**kwargs)- Get single note by filterfilter(**kwargs)- Filter notesadd(object, message, file, force, allow_empty)- Add noteprune(dry_run, verbose)- Prune notesmerge(notes_ref, strategy, commit, abort, quiet)- Merge notesget_ref()- Get notes refAdd
GitNoteCmd(git.notes.get(...)) - instance-based note operationsshow()- Show noteappend(message)- Append to notecopy(from_object)- Copy noteremove()- Remove noteAdd
GitSubmoduleManager(git.submodules) - collection-level submodule operationsls()- List submodules, returnsQueryList[GitSubmoduleEntryCmd]get(**kwargs)- Get single submodule by filterfilter(**kwargs)- Filter submodulesadd(url, path, branch, name, force)- Add submoduleforeach(command, recursive)- Execute in each submodulesync(recursive)- Sync submodule URLssummary(commit, files, cached)- Summarize changesAdd
GitSubmoduleEntryCmd(git.submodules.get(...)) - instance-based submodule operationsinit()- Initialize this submoduleupdate(init, force, checkout, rebase, merge, recursive)- Updatedeinit(force)- Unregister submoduleset_branch(branch)- Set branchset_url(url)- Set URLstatus()- Show statusabsorbgitdirs()- Absorb gitdirAdd
GitReflogManager(git.reflog) - collection-level reflog operationsls(ref)- List reflog entries, returnsQueryList[GitReflogEntryCmd]get(**kwargs)- Get single entry by filterfilter(**kwargs)- Filter entriesexpire(ref, _all, dry_run, rewrite, ...)- Expire entriesexists(ref)- Check if reflog existsAdd
GitReflogEntryCmd(git.reflog.get(...)) - instance-based reflog operationsshow()- Show entry detailsdelete(rewrite, updateref)- Delete entryEnhance
Git.init()- additional parameters and validationref_format---ref-format(files/reftable)make_parents- Auto-create parent directories (default: True)shared- Extended to support octal permissions (e.g., "0660")