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

Use the Git class type definition within Repo classmethods#1322

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

Merged
Byron merged 1 commit intogitpython-developers:mainfrommmulich:main
Aug 18, 2021

Conversation

mmulich
Copy link
Contributor

@mmulichmmulich commentedAug 17, 2021
edited
Loading

Allow the GitCommandWrapperType definition to be used within the Repo
classmethods. This change follows the intended purpose as stated in
the code, "Subclasses may easily bring in their own custom types by
placing a constructor or type here."

The usecase that prompted this change has to do with
GIT_SSH_COMMAND. The goal is to setup a customGit class with
knowledge of the value, something like as follows

fromgitimportGitasBaseGit,RepoasBaseRepoclassGit(BaseGit):def__init__(self,*args,**kwargs):super().__init__(*args,**kwargs)# For example, assign the SSH command using the current flask# app's configured setting.self.update_environment(GIT_SSH_COMMAND=current_app.config['GIT_SSH_COMMAND'])classRepo(BaseRepo):GitCommandWrapperType=Git

With this change, the above example will allow the developer to use
Repo.clone_from(...) with the intended outcome. Otherwise the
developer will have two differing result when usingRepo(...) vs
Repo.clone_from(...).

Allow the GitCommandWrapperType definition to be used within the Repoclassmethods. This change follows the intended purpose as stated inthe code, "Subclasses may easily bring in their own custom types byplacing a constructor or type here."The usecase that prompted this change has to do with`GIT_SSH_COMMAND`. The goal is to setup a custom `Git` class withknowledge of the value, something like as follows```pythonfrom git import Git as BaseGit, Repo as BaseRepoclass Git(BaseGit):    def __init__(self, *args, **kwargs):        super().__init__(*args, **kwargs)        # For example, assign the SSH command using the current flask        # app's configured setting.        self.update_environment(GIT_SSH_COMMAND=current_app.config['GIT_SSH_COMMAND'])class Repo(BaseRepo):    GitCommandWrapperType = _Git```With this change, the above example will allow the developer to use`Repo.clone_from(...)` with the indended outcome. Otherwise thedeveloper will have two differing result when using `Repo(...)` vs`Repo.clone_from(...)`.
@mmulich
Copy link
ContributorAuthor

I believe this could help address issues around confusing usage of an SSH key when usingRepo.clone_from. For example,#400#725#866 and#916 to name a few. Or at least this may be a step towards it. The use ofRepo.GitCommandWrapperType as stated in my example would need to be documented, but first things first... fix the implementation.

Thanks for having simple contribution instructions.

Byron added a commit that referenced this pull requestAug 18, 2021
@Byron
Copy link
Member

Thanks a lot for the fix for this long-standing oversight, it's much appreciated!

And thanks for the hint, I looked at the contribution guidelines and found it outdated, that's fixed now to hopefully further improve the experience.

@ByronByron merged commit1207747 intogitpython-developers:mainAug 18, 2021
@ByronByron added this to thev3.1.21 - Bugfixes milestoneAug 18, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
@mmulich@Byron

[8]ページ先頭

©2009-2025 Movatter.jp