submodule#

For git-submodule(1).

class libvcs.cmd.git.GitSubmoduleCmd(*, dir, cmd=None)[source]#

Bases: object

Run submodule commands in a git repository.

Lite, typed, pythonic wrapper for git-submodule(1).

Parameters:
  • dir (Union[str, PathLike[str]]) – Operates as PATH in the corresponding git subcommand.

  • cmd (Git | None) –

Examples

>>> GitSubmoduleCmd(dir=tmp_path)
<GitSubmoduleCmd dir=...>
>>> GitSubmoduleCmd(dir=tmp_path).run(quiet=True)
'fatal: not a git repository (or any of the parent directories): .git'
>>> GitSubmoduleCmd(dir=git_local_clone.dir).run(quiet=True)
''
__init__(*, dir, cmd=None)[source]#

Lite, typed, pythonic wrapper for git-submodule(1).

Parameters:
  • dir (Union[str, PathLike[str]]) – Operates as PATH in the corresponding git subcommand.

  • cmd (Git | None) –

Return type:

None

Examples

>>> GitSubmoduleCmd(dir=tmp_path)
<GitSubmoduleCmd dir=...>
>>> GitSubmoduleCmd(dir=tmp_path).run(quiet=True)
'fatal: not a git repository (or any of the parent directories): .git'
>>> GitSubmoduleCmd(dir=git_local_clone.dir).run(quiet=True)
''
dir: Path#

Directory to check out

run(command=None, local_flags=None, *, quiet=None, cached=None, log_in_real_time=False, check_returncode=None, **kwargs)[source]#

Run a command against a git submodule.

Wraps git submodule.

Return type:

str

Parameters:
  • command (Literal['status', 'init', 'deinit', 'update', 'set-branch', 'set-url', 'summary', 'foreach', 'sync', 'absorbgitdirs'] | None) –

  • local_flags (list[str] | None) –

  • quiet (bool | None) –

  • cached (bool | None) –

  • log_in_real_time (bool) –

  • check_returncode (bool | None) –

  • kwargs (Any) –

Examples

>>> GitSubmoduleCmd(dir=git_local_clone.dir).run()
''
init(*, path=None, log_in_real_time=False, check_returncode=None)[source]#

Git submodule init.

Return type:

str

Parameters:

Examples

>>> GitSubmoduleCmd(dir=git_local_clone.dir).init()
''
update(*, path=None, init=None, force=None, checkout=None, rebase=None, merge=None, recursive=None, log_in_real_time=False, check_returncode=None, **kwargs)[source]#

Git submodule update.

Return type:

str

Parameters:
  • path (list[str | PathLike[str]] | str | PathLike[str] | None) –

  • init (bool | None) –

  • force (bool | None) –

  • checkout (bool | None) –

  • rebase (bool | None) –

  • merge (bool | None) –

  • recursive (bool | None) –

  • log_in_real_time (bool) –

  • check_returncode (bool | None) –

  • kwargs (Any) –

Examples

>>> GitSubmoduleCmd(dir=git_local_clone.dir).update()
''
>>> GitSubmoduleCmd(dir=git_local_clone.dir).update(init=True)
''
>>> GitSubmoduleCmd(dir=git_local_clone.dir).update(init=True, recursive=True)
''
>>> GitSubmoduleCmd(dir=git_local_clone.dir).update(force=True)
''
>>> GitSubmoduleCmd(dir=git_local_clone.dir).update(checkout=True)
''
>>> GitSubmoduleCmd(dir=git_local_clone.dir).update(rebase=True)
''
>>> GitSubmoduleCmd(dir=git_local_clone.dir).update(merge=True)
''