-
Notifications
You must be signed in to change notification settings - Fork 12
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
cmd(git): More commands #465
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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 ☔ View full report in Codecov by Sentry. |
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
2d78366
to
8ad81a7
Compare
6a0495c
to
1617b69
Compare
@sourcery-ai review |
Reviewer's Guide by SourceryThis pull request introduces a new way to manage Git branches using a new instance-based approach. It adds a Sequence diagram for branch creation and checkoutsequenceDiagram
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 changesclassDiagram
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
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tony - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/libvcs/cmd/git.py
Outdated
@@ -390,7 +395,7 @@ def clone( | |||
def fetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Low code quality found in Git.fetch - 6% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
src/libvcs/cmd/git.py
Outdated
@@ -746,7 +751,7 @@ | |||
def pull( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Low code quality found in Git.pull - 1% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
src/libvcs/cmd/git.py
Outdated
if isinstance(path, pathlib.Path): | ||
self.path = path | ||
else: | ||
self.path = pathlib.Path(path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Replace if statement with if expression (assign-if-exp
)
if isinstance(path, pathlib.Path): | |
self.path = path | |
else: | |
self.path = pathlib.Path(path) | |
self.path = path if isinstance(path, pathlib.Path) else pathlib.Path(path) |
|
||
if mirror is not None: | ||
if isinstance(mirror, str): | ||
assert any(f for f in ["push", "fetch"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Simplify generator expression (simplify-generator
)
assert any(f for f in ["push", "fetch"]) | |
assert any(["push", "fetch"]) |
if isinstance(path, pathlib.Path): | ||
self.path = path | ||
else: | ||
self.path = pathlib.Path(path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Replace if statement with if expression (assign-if-exp
)
if isinstance(path, pathlib.Path): | |
self.path = path | |
else: | |
self.path = pathlib.Path(path) | |
self.path = path if isinstance(path, pathlib.Path) else pathlib.Path(path) |
if isinstance(path, pathlib.Path): | ||
self.path = path | ||
else: | ||
self.path = pathlib.Path(path) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Replace if statement with if expression (assign-if-exp
)
if isinstance(path, pathlib.Path): | |
self.path = path | |
else: | |
self.path = pathlib.Path(path) | |
self.path = path if isinstance(path, pathlib.Path) else pathlib.Path(path) |
6c49b71
to
a98c050
Compare
- Add support for all git-init options (template, separate_git_dir, object_format, etc.) - Add comprehensive tests for each option - Fix path handling for separate_git_dir - Fix string formatting for bytes paths - Update docstrings with examples for all options
- Enhance Git.init docstrings with detailed parameter descriptions - Add comprehensive examples including SHA-256 object format - Add return value and exception documentation - Improve type hints for shared parameter with Literal types - Add extensive validation tests for all parameters
- Add validation for template parameter type and existence - Add validation for object_format parameter values - Improve type formatting for shared parameter - Complete docstring example output
- Add ref-format parameter support for git init - Add make_parents parameter to control directory creation - Improve type hints and validation for template and shared parameters - Add comprehensive tests for all shared values and octal permissions - Add validation for octal number range in shared parameter
Changes
Commands (git)
Add
GitBranch
(git.branch
) - instance-based mutations of a branchgit checkout -b <branchname>
git checkout <branchname>
Summary by Sourcery
Add the
GitBranchManager
to manage Git branches. UpdateGitRemoteCmd
toGitRemoteManager
.New Features:
GitBranch
class to provide instance-based mutations of a branch, including creating, checking out, removing, renaming, and moving branches.Tests:
GitRemoteCmd
andGitBranch
classes.