libvcs
libvcs copied to clipboard
cmd(git): More commands
Changes
Commands (git)
Add GitBranch (git.branch) - instance-based mutations of a branch
- Create
git checkout -b <branchname> - Checkout
git checkout <branchname> - Remove
- Rename
- Move
Summary by Sourcery
Add the GitBranchManager to manage Git branches. Update GitRemoteCmd to GitRemoteManager.
New Features:
- Add a
GitBranchclass to provide instance-based mutations of a branch, including creating, checking out, removing, renaming, and moving branches.
Tests:
- Update tests to reflect the changes in the
GitRemoteCmdandGitBranchclasses.
Codecov Report
Attention: Patch coverage is 78.88199% with 68 lines in your changes missing coverage. Please review.
Project coverage is 56.57%. Comparing base (
43b41ab) to head (908b72a).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/libvcs/cmd/git.py | 65.21% | 55 Missing and 9 partials :warning: |
| tests/cmd/test_git.py | 96.77% | 4 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #465 +/- ##
==========================================
+ Coverage 54.09% 56.57% +2.47%
==========================================
Files 40 40
Lines 3627 3894 +267
Branches 793 822 +29
==========================================
+ Hits 1962 2203 +241
- Misses 1314 1333 +19
- Partials 351 358 +7
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@sourcery-ai review
Reviewer's Guide by Sourcery
This pull request introduces a new way to manage Git branches using a new instance-based approach. It adds a GitBranchManager class and a GitBranchCmd class, which provide methods for creating, checking out, removing, renaming, and moving branches. It also refactors the GitRemoteCmd class to GitRemoteManager and GitRemoteCmd to provide a similar instance-based approach for managing remotes.
Sequence diagram for branch creation and checkout
sequenceDiagram
participant Client
participant Git
participant GitBranchManager
participant GitBranchCmd
Client->>Git: branches.create(branch='feature')
Git->>GitBranchManager: create(branch='feature')
GitBranchManager->>GitBranchCmd: new GitBranchCmd(branch_name='feature')
GitBranchCmd-->>GitBranchManager: branch command object
GitBranchManager->>GitBranchCmd: create()
GitBranchCmd-->>GitBranchManager: result
GitBranchManager-->>Git: result
Git-->>Client: result
Class diagram for Git branch and remote management changes
classDiagram
class Git {
+remotes: GitRemoteManager
+branches: GitBranchManager
+stash: GitStashCmd
}
class GitRemoteManager {
+path: Path
+run()
+add()
+show()
+ls(): QueryList[GitRemoteCmd]
+get(): GitRemoteCmd
+filter(): list[GitRemoteCmd]
}
class GitRemoteCmd {
+remote_name: str
+fetch_url: str
+push_url: str
+rename()
+remove()
+show()
+prune()
+get_url()
+set_url()
}
class GitBranchManager {
+path: Path
+run()
+checkout()
+create()
+ls(): QueryList[GitBranchCmd]
+get(): GitBranchCmd
+filter(): list[GitBranchCmd]
}
class GitBranchCmd {
+branch_name: str
+checkout()
+create()
}
Git *-- GitRemoteManager
Git *-- GitBranchManager
GitRemoteManager ..> GitRemoteCmd : creates
GitBranchManager ..> GitBranchCmd : creates
note for GitRemoteManager "New instance-based approach"
note for GitBranchManager "New instance-based approach"
File-Level Changes
| Change | Details | Files |
|---|---|---|
Added GitBranchManager and GitBranchCmd classes for managing Git branches. |
|
src/libvcs/cmd/git.py |
Refactored GitRemoteCmd to GitRemoteManager and GitRemoteCmd. |
|
src/libvcs/cmd/git.pysrc/libvcs/sync/git.pytests/sync/test_git.py |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it.
- Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted.
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.