remote
¶
For git-remote(1)
.
- class libvcs.cmd.git.GitRemoteCmd(*, path, cmd=None)[source]¶
Bases:
object
Run commands directly for a git remote on a git repository.
Lite, typed, pythonic wrapper for git-remote(1).
- Parameters:
Examples
>>> GitRemoteCmd(path=tmp_path) <GitRemoteCmd path=...>
>>> GitRemoteCmd(path=tmp_path).run(verbose=True) 'fatal: not a git repository (or any of the parent directories): .git'
>>> GitRemoteCmd(path=example_git_repo.path).run(verbose=True) 'origin\tfile:///...'
- __init__(*, path, cmd=None)[source]¶
Lite, typed, pythonic wrapper for git-remote(1).
- Parameters:
- Return type:
None
Examples
>>> GitRemoteCmd(path=tmp_path) <GitRemoteCmd path=...>
>>> GitRemoteCmd(path=tmp_path).run(verbose=True) 'fatal: not a git repository (or any of the parent directories): .git'
>>> GitRemoteCmd(path=example_git_repo.path).run(verbose=True) 'origin\tfile:///...'
-
path:
Path
¶ Directory to check out
- run(command=None, local_flags=None, *, verbose=None, log_in_real_time=False, check_returncode=None, **kwargs)[source]¶
Run command against a git remote.
Wraps git remote.
- Return type:
- Parameters:
Examples
>>> GitRemoteCmd(path=example_git_repo.path).run() 'origin' >>> GitRemoteCmd(path=example_git_repo.path).run(verbose=True) 'origin\tfile:///...'
- add(*, name, url, fetch=None, track=None, master=None, mirror=None, log_in_real_time=False, check_returncode=None)[source]¶
Git remote add.
- Return type:
- Parameters:
Examples
>>> git_remote_repo = create_git_remote_repo() >>> GitRemoteCmd(path=example_git_repo.path).add( ... name='my_remote', url=f'file://{git_remote_repo}' ... ) ''
- rename(*, old, new, progress=None, log_in_real_time=False, check_returncode=None)[source]¶
Git remote rename.
- Return type:
- Parameters:
Examples
>>> git_remote_repo = create_git_remote_repo() >>> GitRemoteCmd( ... path=example_git_repo.path ... ).rename(old='origin', new='new_name') '' >>> GitRemoteCmd(path=example_git_repo.path).run() 'new_name'
- remove(*, name, log_in_real_time=False, check_returncode=None)[source]¶
Git remote remove.
Examples
>>> GitRemoteCmd(path=example_git_repo.path).remove(name='origin') '' >>> GitRemoteCmd(path=example_git_repo.path).run() ''
- show(*, name=None, verbose=None, no_query_remotes=None, log_in_real_time=False, check_returncode=None)[source]¶
Git remote show.
- Return type:
- Parameters:
Examples
>>> GitRemoteCmd(path=example_git_repo.path).show() 'origin'
- prune(*, name, dry_run=None, log_in_real_time=False, check_returncode=None)[source]¶
Git remote prune.
- Return type:
- Parameters:
Examples
>>> git_remote_repo = create_git_remote_repo() >>> GitRemoteCmd(path=example_git_repo.path).prune(name='origin') ''
>>> GitRemoteCmd(path=example_git_repo.path).prune(name='origin', dry_run=True) ''
- get_url(*, name, push=None, _all=None, log_in_real_time=False, check_returncode=None)[source]¶
Git remote get-url.
- Return type:
- Parameters:
Examples
>>> git_remote_repo = create_git_remote_repo() >>> GitRemoteCmd(path=example_git_repo.path).get_url(name='origin') 'file:///...'
>>> GitRemoteCmd(path=example_git_repo.path).get_url(name='origin', push=True) 'file:///...'
>>> GitRemoteCmd(path=example_git_repo.path).get_url(name='origin', _all=True) 'file:///...'
- 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.
- Return type:
- Parameters:
Examples
>>> git_remote_repo = create_git_remote_repo() >>> GitRemoteCmd(path=example_git_repo.path).set_url( ... name='origin', ... url='http://localhost' ... ) ''
>>> GitRemoteCmd(path=example_git_repo.path).set_url( ... name='origin', ... url='http://localhost', ... push=True ... ) ''
>>> GitRemoteCmd(path=example_git_repo.path).set_url( ... name='origin', ... url='http://localhost', ... add=True ... ) ''
>>> current_url = GitRemoteCmd( ... path=example_git_repo.path, ... ).get_url(name='origin') >>> GitRemoteCmd(path=example_git_repo.path).set_url( ... name='origin', ... url=current_url, ... delete=True ... ) 'fatal: Will not delete all non-push URLs'