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

Commit1207747

Browse files
mmulichByron
authored andcommitted
Use the Git class type definition within Repo classmethods
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(...)`.
1 parentbd0fa88 commit1207747

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎git/repo/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ def init(cls, path: Union[PathLike, None] = None, mkdir: bool = True, odbt: Type
10421042
os.makedirs(path,0o755)
10431043

10441044
# git command automatically chdir into the directory
1045-
git=Git(path)
1045+
git=cls.GitCommandWrapperType(path)
10461046
git.init(**kwargs)
10471047
returncls(path,odbt=odbt)
10481048

@@ -1142,7 +1142,7 @@ def clone_from(cls, url: PathLike, to_path: PathLike, progress: Optional[Callabl
11421142
:param multi_options: See ``clone`` method
11431143
:param kwargs: see the ``clone`` method
11441144
:return: Repo instance pointing to the cloned directory"""
1145-
git=Git(os.getcwd())
1145+
git=cls.GitCommandWrapperType(os.getcwd())
11461146
ifenvisnotNone:
11471147
git.update_environment(**env)
11481148
returncls._clone(git,url,to_path,GitCmdObjectDB,progress,multi_options,**kwargs)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp