submodule¶

For git-submodule(1).

class libvcs.cmd.git.GitSubmoduleCmd(*, path, cmd=None)[source]¶

Bases: object

Run submodule commands in a git repository.

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

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

  • cmd (Git | None)

Examples

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

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

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

  • cmd (Git | None)

Return type:

None

Examples

>>> GitSubmoduleCmd(path=tmp_path)
<GitSubmoduleCmd path=...>
>>> GitSubmoduleCmd(path=tmp_path).run(quiet=True)
'fatal: not a git repository (or any of the parent directories): .git'
>>> GitSubmoduleCmd(path=example_git_repo.path).run(quiet=True)
''
path: 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(path=example_git_repo.path).run()
''
init(*, path=None, log_in_real_time=False, check_returncode=None)[source]¶

Git submodule init.

Return type:

str

Parameters:

Examples

>>> GitSubmoduleCmd(path=example_git_repo.path).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:

Examples

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