git_well.git_remote_protocol module¶
- class git_well.git_remote_protocol.GitRemoteProtocol(*args, **kwargs)[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
- default = {'group': <Value('special:auto')>, 'protocol': <Value('ssh')>, 'repo_dpath': <Value('.')>}¶
- main(**kwargs)¶
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') >>> cmdline = 0 >>> GitRemoteProtocol.main(cmdline=cmdline, 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(cmdline=cmdline, repo_dpath=repo, protocol='https') >>> assert list(repo.remotes[0].urls)[0] == 'https://github.com/Foobar/foobar.git' >>> GitRemoteProtocol.main(cmdline=cmdline, repo_dpath=repo, protocol='git') >>> assert list(repo.remotes[0].urls)[0] == 'git@github.com:Foobar/foobar.git'
- class git_well.git_remote_protocol.GitURL(data)[source]¶
Bases:
str
Represents a url to a git repo and can parse info about / modify the protocol
References
https://git-scm.com/docs/git-clone#_git_urls
CommandLine
xdoctest -m git_well.git_remote_protocol GitURL
Example
>>> from git_well.git_remote_protocol import * # NOQA >>> urls = [ >>> GitURL('https://foo.bar/user/repo.git'), >>> GitURL('ssh://foo.bar/user/repo.git'), >>> GitURL('ssh://git@foo.bar/user/repo.git'), >>> GitURL('git@foo.bar:group/repo.git'), >>> GitURL('host:path/to/my/repo/.git'), >>> ] >>> for url in urls: >>> print('---') >>> print(f'url = {url}') >>> print(ub.urepr(url.info)) >>> print('As git : ' + url.to_git()) >>> print('As ssh : ' + url.to_ssh()) >>> print('As https : ' + url.to_https())
- property info¶
- git_well.git_remote_protocol.main(cmdline=1, **kwargs)[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') >>> cmdline = 0 >>> GitRemoteProtocol.main(cmdline=cmdline, 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(cmdline=cmdline, repo_dpath=repo, protocol='https') >>> assert list(repo.remotes[0].urls)[0] == 'https://github.com/Foobar/foobar.git' >>> GitRemoteProtocol.main(cmdline=cmdline, repo_dpath=repo, protocol='git') >>> assert list(repo.remotes[0].urls)[0] == 'git@github.com:Foobar/foobar.git'