Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
tony wants to merge6 commits intomaster
base:master
Choose a base branch
Loading
frommore-git-cmds
Open

cmd(git): More commands#465

tony wants to merge6 commits intomasterfrommore-git-cmds

Conversation

@tony
Copy link
Member

@tonytony commentedJun 18, 2024
edited by sourcery-aibot
Loading

Changes

Commands (git)

AddGitBranch (git.branch) - instance-based mutations of a branch

  • Creategit checkout -b <branchname>
  • Checkoutgit checkout <branchname>
  • Remove
  • Rename
  • Move

Summary by Sourcery

Add theGitBranchManager to manage Git branches. UpdateGitRemoteCmd toGitRemoteManager.

New Features:

  • Add aGitBranch class 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 theGitRemoteCmd andGitBranch classes.

@codecov
Copy link

codecovbot commentedJun 18, 2024
edited
Loading

Codecov Report

Attention: Patch coverage is78.88199% with68 lines in your changes missing coverage. Please review.

Project coverage is 56.57%. Comparing base(43b41ab) to head(908b72a).

Files with missing linesPatch %Lines
src/libvcs/cmd/git.py65.21%55 Missing and 9 partials⚠️
tests/cmd/test_git.py96.77%4 Missing⚠️
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.
📢 Have feedback on the report?Share it here.

@tonytonyforce-pushed themore-git-cmds branch 3 times, most recently fromff046f3 to5dff81eCompareJune 24, 2024 00:02
@tonytonyforce-pushed themore-git-cmds branch 8 times, most recently from8808231 to700a4faCompareJuly 4, 2024 23:01
@tonytonyforce-pushed themore-git-cmds branch 3 times, most recently fromf520132 toaf58b49CompareJuly 20, 2024 11:39
@tonytonyforce-pushed themore-git-cmds branch 2 times, most recently fromadfbeaa to76822c5CompareAugust 3, 2024 12:20
@tonytonyforce-pushed themore-git-cmds branch 4 times, most recently from8adff4c toc843022CompareAugust 10, 2024 19:57
@tonytonyforce-pushed themore-git-cmds branch 3 times, most recently from8839c2a to0385215CompareAugust 16, 2024 23:56
@tonytonyforce-pushed themore-git-cmds branch 2 times, most recently from11dbd6a to8578585CompareAugust 26, 2024 10:50
@tonytonyforce-pushed themore-git-cmds branch 4 times, most recently from2e5347d tobb6d40eCompareSeptember 6, 2024 23:56
@tony
Copy link
MemberAuthor

@sourcery-ai review

sourcery-ai[bot] reacted with eyes emoji

@sourcery-ai
Copy link

Reviewer's Guide by Sourcery

This pull request introduces a new way to manage Git branches using a new instance-based approach. It adds aGitBranchManager class and aGitBranchCmd class, which provide methods for creating, checking out, removing, renaming, and moving branches. It also refactors theGitRemoteCmd class toGitRemoteManager andGitRemoteCmd 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
Loading

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"
Loading

File-Level Changes

ChangeDetailsFiles
AddedGitBranchManager andGitBranchCmd classes for managing Git branches.
  • Introduced theGitBranchManager class to manage Git branches.
  • Introduced theGitBranchCmd class to perform operations on individual branches.
  • Added abranches attribute to theGit class to access theGitBranchManager.
  • Added methods toGitBranchManager for creating, checking out, removing, renaming, and moving branches.
  • Added methods toGitBranchCmd for performing operations on individual branches, such as checking out and creating branches.
src/libvcs/cmd/git.py
RefactoredGitRemoteCmd toGitRemoteManager andGitRemoteCmd.
  • Introduced theGitRemoteManager class to manage Git remotes.
  • Introduced theGitRemoteCmd class to perform operations on individual remotes.
  • Changed theremotes attribute of theGit class to access theGitRemoteManager.
  • Updated theGitSync class to use the newGitRemoteManager.
  • Updated tests to reflect the changes in theGitRemoteCmd andGitSync classes.
src/libvcs/cmd/git.py
src/libvcs/sync/git.py
tests/sync/test_git.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment@sourcery-ai review on 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-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write@sourcery-ai summary anywhere 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 yourdashboard 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

Copy link

@sourcery-aisourcery-aibot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
log_in_real_time=log_in_real_time,
)

deffetch(

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)


ExplanationThe 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.

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
check_returncode=check_returncode,
)

defpull(

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)


ExplanationThe 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.

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
Comment on lines 2792 to 2959
ifisinstance(path,pathlib.Path):
self.path=path
else:
self.path=pathlib.Path(path)

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)

Suggested change
ifisinstance(path,pathlib.Path):
self.path=path
else:
self.path=pathlib.Path(path)
self.path=pathifisinstance(path,pathlib.Path)elsepathlib.Path(path)

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji

ifmirrorisnotNone:
ifisinstance(mirror,str):
assertany(fforfin ["push","fetch"])

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)

Suggested change
assertany(fforfin["push","fetch"])
assertany(["push","fetch"])

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
Comment on lines +3336 to +3503
ifisinstance(path,pathlib.Path):
self.path=path
else:
self.path=pathlib.Path(path)

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)

Suggested change
ifisinstance(path,pathlib.Path):
self.path=path
else:
self.path=pathlib.Path(path)
self.path=pathifisinstance(path,pathlib.Path)elsepathlib.Path(path)

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
Comment on lines +3459 to +3626
ifisinstance(path,pathlib.Path):
self.path=path
else:
self.path=pathlib.Path(path)

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)

Suggested change
ifisinstance(path,pathlib.Path):
self.path=path
else:
self.path=pathlib.Path(path)
self.path=pathifisinstance(path,pathlib.Path)elsepathlib.Path(path)

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
@tonytonyforce-pushed themore-git-cmds branch 6 times, most recently from6c49b71 toa98c050CompareFebruary 23, 2025 11:44
- 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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@sourcery-aisourcery-ai[bot]sourcery-ai[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@tony

[8]ページ先頭

©2009-2025 Movatter.jp