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

Commit24f75e7

Browse files
isoloveyByron
authored andcommitted
Added ability to define git environment in submodule add/update methods
1 parentbfbd5ec commit24f75e7

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎git/objects/submodule/base.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
309309
#{ Edit Interface
310310

311311
@classmethod
312-
defadd(cls,repo,name,path,url=None,branch=None,no_checkout=False,depth=None):
312+
defadd(cls,repo,name,path,url=None,branch=None,no_checkout=False,depth=None,env=None):
313313
"""Add a new submodule to the given repository. This will alter the index
314314
as well as the .gitmodules file, but will not create a new commit.
315315
If the submodule already exists, no matter if the configuration differs
@@ -336,6 +336,12 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False, depth=N
336336
no checkout will be performed
337337
:param depth: Create a shallow clone with a history truncated to the
338338
specified number of commits.
339+
:param env: Optional dictionary containing the desired environment variables.
340+
Note: Provided variables will be used to update the execution
341+
environment for `git`. If some variable is not specified in `env`
342+
and is defined in `os.environ`, value from `os.environ` will be used.
343+
If you want to unset some variable, consider providing empty string
344+
as its value.
339345
:return: The newly created submodule instance
340346
:note: works atomically, such that no change will be done if the repository
341347
update fails for instance"""
@@ -404,7 +410,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False, depth=N
404410
raiseValueError("depth should be an integer")
405411

406412
# _clone_repo(cls, repo, url, path, name, **kwargs):
407-
mrepo=cls._clone_repo(repo,url,path,name,**kwargs)
413+
mrepo=cls._clone_repo(repo,url,path,name,env=env,**kwargs)
408414
# END verify url
409415

410416
## See #525 for ensuring git urls in config-files valid under Windows.
@@ -436,7 +442,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False, depth=N
436442
returnsm
437443

438444
defupdate(self,recursive=False,init=True,to_latest_revision=False,progress=None,dry_run=False,
439-
force=False,keep_going=False):
445+
force=False,keep_going=False,env=None):
440446
"""Update the repository of this submodule to point to the checkout
441447
we point at with the binsha of this instance.
442448
@@ -461,6 +467,12 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
461467
Unless dry_run is set as well, keep_going could cause subsequent/inherited errors you wouldn't see
462468
otherwise.
463469
In conjunction with dry_run, it can be useful to anticipate all errors when updating submodules
470+
:param env: Optional dictionary containing the desired environment variables.
471+
Note: Provided variables will be used to update the execution
472+
environment for `git`. If some variable is not specified in `env`
473+
and is defined in `os.environ`, value from `os.environ` will be used.
474+
If you want to unset some variable, consider providing empty string
475+
as its value.
464476
:note: does nothing in bare repositories
465477
:note: method is definitely not atomic if recurisve is True
466478
:return: self"""
@@ -527,7 +539,7 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
527539
progress.update(BEGIN|CLONE,0,1,prefix+"Cloning url '%s' to '%s' in submodule %r"%
528540
(self.url,checkout_module_abspath,self.name))
529541
ifnotdry_run:
530-
mrepo=self._clone_repo(self.repo,self.url,self.path,self.name,n=True)
542+
mrepo=self._clone_repo(self.repo,self.url,self.path,self.name,n=True,env=env)
531543
# END handle dry-run
532544
progress.update(END|CLONE,0,1,prefix+"Done cloning to %s"%checkout_module_abspath)
533545

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp