git_well._utils module

git_well._utils.rich_print(*args: Any, **kwargs: Any) Any[source]
git_well._utils.find_merged_branches(repo: Any, main_branch: str = 'main') Any[source]
git_well._utils.confirm(msg: str) bool[source]
git_well._utils.choice_prompt(msg: str, choices: list[str]) str[source]
git_well._utils.find_git_root(dpath: str | PathLike[str]) Path[source]
class git_well._utils.GitURL(data: str)[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
>>> from git_well._utils 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:
>>>     info = url.info
>>>     print('---')
>>>     print(f'url = {url}')
>>>     print(ub.urepr(info))
>>>     print('As git   : ' + url.to_git())
>>>     print('As ssh   : ' + url.to_ssh())
>>>     print('As https : ' + url.to_https())
>>>     if info['protocol'] not in {'scp'}:
>>>         # SCP recon is broken
>>>         recon = url.to_protocol(info['protocol'])
>>>         assert recon == url
_parse() None[source]
_fixup_endpoint(repo_endpoint: str) tuple[str, str][source]
property info: dict[str, Any]
to_protocol(protocol: str) GitURL[source]

Convert the URL to a different protocol

to_git() GitURL[source]
to_ssh() GitURL[source]
to_https() GitURL[source]