remote#

For git-remote(1).

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

Bases: object

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

Parameters:

Examples

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

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

Parameters:
Return type:

None

Examples

>>> GitRemoteCmd(dir=tmp_path)
<GitRemoteCmd dir=...>
>>> GitRemoteCmd(dir=tmp_path).run(verbose=True)
'fatal: not a git repository (or any of the parent directories): .git'
>>> GitRemoteCmd(dir=git_local_clone.dir).run(verbose=True)
'origin\tfile:///...'
dir: Path#

Directory to check out

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

Wraps git remote.

Examples

>>> GitRemoteCmd(dir=git_local_clone.dir).run()
'origin'
>>> GitRemoteCmd(dir=git_local_clone.dir).run(verbose=True)
'origin\tfile:///...'
Return type:

str

Parameters:
  • command (Optional[Literal['add', 'rename', 'remove', 'set-branches', 'set-head', 'set-branch', 'get-url', 'set-url', 'set-url --add', 'set-url --delete', 'prune', 'show', 'update']]) –

  • local_flags (Optional[list[str]]) –

  • verbose (Optional[bool]) –

  • log_in_real_time (bool) –

  • check_returncode (Optional[bool]) –

  • kwargs (Any) –

add(*, name, url, fetch=None, track=None, master=None, mirror=None, log_in_real_time=False, check_returncode=None)[source]#

git remote add

Examples

>>> git_remote_repo = create_git_remote_repo()
>>> GitRemoteCmd(dir=git_local_clone.dir).add(
...     name='my_remote', url=f'file://{git_remote_repo}'
... )
''
Return type:

str

Parameters:
rename(*, old, new, progress=None, log_in_real_time=False, check_returncode=None)[source]#

git remote rename

Examples

>>> git_remote_repo = create_git_remote_repo()
>>> GitRemoteCmd(dir=git_local_clone.dir).rename(old='origin', new='new_name')
''
>>> GitRemoteCmd(dir=git_local_clone.dir).run()
'new_name'
Return type:

str

Parameters:
remove(*, name, log_in_real_time=False, check_returncode=None)[source]#

git remote remove

Examples

>>> GitRemoteCmd(dir=git_local_clone.dir).remove(name='origin')
''
>>> GitRemoteCmd(dir=git_local_clone.dir).run()
''
Return type:

str

Parameters:
show(*, name=None, verbose=None, no_query_remotes=None, log_in_real_time=False, check_returncode=None)[source]#

git remote show

Examples

>>> GitRemoteCmd(dir=git_local_clone.dir).show()
'origin'
Return type:

str

Parameters:
prune(*, name, dry_run=None, log_in_real_time=False, check_returncode=None)[source]#

git remote prune

Examples

>>> git_remote_repo = create_git_remote_repo()
>>> GitRemoteCmd(dir=git_local_clone.dir).prune(name='origin')
''
>>> GitRemoteCmd(dir=git_local_clone.dir).prune(name='origin', dry_run=True)
''
Return type:

str

Parameters:
get_url(*, name, push=None, all=None, log_in_real_time=False, check_returncode=None)[source]#

git remote get-url

Examples

>>> git_remote_repo = create_git_remote_repo()
>>> GitRemoteCmd(dir=git_local_clone.dir).get_url(name='origin')
'file:///...'
>>> GitRemoteCmd(dir=git_local_clone.dir).get_url(name='origin', push=True)
'file:///...'
>>> GitRemoteCmd(dir=git_local_clone.dir).get_url(name='origin', all=True)
'file:///...'
Return type:

str

Parameters:
set_url(*, name, url, old_url=None, push=None, add=None, delete=None, log_in_real_time=False, check_returncode=None)[source]#

git remote set-url

Examples

>>> git_remote_repo = create_git_remote_repo()
>>> GitRemoteCmd(dir=git_local_clone.dir).set_url(
...     name='origin',
...     url='http://localhost'
... )
''
>>> GitRemoteCmd(dir=git_local_clone.dir).set_url(
...     name='origin',
...     url='http://localhost',
...     push=True
... )
''
>>> GitRemoteCmd(dir=git_local_clone.dir).set_url(
...     name='origin',
...     url='http://localhost',
...     add=True
... )
''
>>> current_url = GitRemoteCmd(dir=git_local_clone.dir).get_url(name='origin')
>>> GitRemoteCmd(dir=git_local_clone.dir).set_url(
...     name='origin',
...     url=current_url,
...     delete=True
... )
'fatal: Will not delete all non-push URLs'
Return type:

str

Parameters: