git_well.git_remote_protocol module

class git_well.git_remote_protocol.GitRemoteProtocol(*args: Any, **kwargs: Any)[source]

Bases: DataConfig

Change the protocol for all remotes that match a specific user / group.

The new protocol can be git or https.

An alias for this command is git permit because it “permits” a specific group to use ssh permissions.

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

group: Value
protocol: Value
repo_dpath: Value
default = {'group': <Value('special:auto')>, 'protocol': <Value('git')>, 'repo_dpath': <Value('.')>}
main(**kwargs: Any) None

Example

>>> from git_well.git_remote_protocol import GitRemoteProtocol
>>> from git_well.repo import Repo
>>> repo = Repo.demo()
>>> repo.cmd('git remote add origin https://github.com/Foobar/foobar.git')
>>> argv = False
>>> GitRemoteProtocol.main(argv=argv, repo_dpath=repo, protocol='git')
>>> assert len(repo.remotes) == 1
>>> assert list(repo.remotes[0].urls)[0] == 'git@github.com:Foobar/foobar.git'
>>> GitRemoteProtocol.main(argv=argv, repo_dpath=repo, protocol='https')
>>> assert list(repo.remotes[0].urls)[0] == 'https://github.com/Foobar/foobar.git'
>>> GitRemoteProtocol.main(argv=argv, repo_dpath=repo, protocol='git')
>>> assert list(repo.remotes[0].urls)[0] == 'git@github.com:Foobar/foobar.git'
git_well.git_remote_protocol.main(argv: list[str] | str | bool | None = True, **kwargs: Any) None[source]

Example

>>> from git_well.git_remote_protocol import GitRemoteProtocol
>>> from git_well.repo import Repo
>>> repo = Repo.demo()
>>> repo.cmd('git remote add origin https://github.com/Foobar/foobar.git')
>>> argv = False
>>> GitRemoteProtocol.main(argv=argv, repo_dpath=repo, protocol='git')
>>> assert len(repo.remotes) == 1
>>> assert list(repo.remotes[0].urls)[0] == 'git@github.com:Foobar/foobar.git'
>>> GitRemoteProtocol.main(argv=argv, repo_dpath=repo, protocol='https')
>>> assert list(repo.remotes[0].urls)[0] == 'https://github.com/Foobar/foobar.git'
>>> GitRemoteProtocol.main(argv=argv, repo_dpath=repo, protocol='git')
>>> assert list(repo.remotes[0].urls)[0] == 'git@github.com:Foobar/foobar.git'