- Notifications
You must be signed in to change notification settings - Fork11
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecovbot commentedJun 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 to5dff81eCompare8808231 to700a4faComparef520132 toaf58b49Compareadfbeaa to76822c5Compare8adff4c toc843022Compare8839c2a to0385215Compare11dbd6a to8578585Compare2e5347d tobb6d40eCompare6a0495c to1617b69Comparetony commentedJan 11, 2025
@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: resultClass 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 yourdashboard 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.
| log_in_real_time=log_in_real_time, | ||
| ) | ||
| deffetch( |
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.
| check_returncode=check_returncode, | ||
| ) | ||
| defpull( |
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.
| ifisinstance(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)
| ifisinstance(path,pathlib.Path): | |
| self.path=path | |
| else: | |
| self.path=pathlib.Path(path) | |
| self.path=pathifisinstance(path,pathlib.Path)elsepathlib.Path(path) |
| ifmirrorisnotNone: | ||
| ifisinstance(mirror,str): | ||
| assertany(fforfin ["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)
| assertany(fforfin["push","fetch"]) | |
| assertany(["push","fetch"]) |
| ifisinstance(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)
| ifisinstance(path,pathlib.Path): | |
| self.path=path | |
| else: | |
| self.path=pathlib.Path(path) | |
| self.path=pathifisinstance(path,pathlib.Path)elsepathlib.Path(path) |
| ifisinstance(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)
| ifisinstance(path,pathlib.Path): | |
| self.path=path | |
| else: | |
| self.path=pathlib.Path(path) | |
| self.path=pathifisinstance(path,pathlib.Path)elsepathlib.Path(path) |
6c49b71 toa98c050Compare- 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
Uh oh!
There was an error while loading.Please reload this page.
Changes
Commands (git)
Add
GitBranch(git.branch) - instance-based mutations of a branchgit checkout -b <branchname>git checkout <branchname>Summary by Sourcery
Add the
GitBranchManagerto manage Git branches. UpdateGitRemoteCmdtoGitRemoteManager.New Features:
GitBranchclass to provide instance-based mutations of a branch, including creating, checking out, removing, renaming, and moving branches.Tests:
GitRemoteCmdandGitBranchclasses.