-
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.08% 54.44% +0.36%
==========================================
Files 40 40
Lines 3635 3745 +110
Branches 793 808 +15
==========================================
+ Hits 1966 2039 +73
- Misses 1318 1350 +32
- Partials 351 356 +5 ☔ 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
a7c9389
to
3eb99a5
Compare
9298d30
to
6547a77
Compare
7f69eab
to
c480bb4
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.
@@ -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.
@@ -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.
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) |
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.