API Reference

Toggle Git remotes between https and ssh.

Classes:

Remote(style, domain, repo, username)

Represents a remote repository.

Toggler(repo, *args, **kwargs)

Toggle Git remotes between https and ssh.

class Remote(style, domain, repo, username)[source]

Bases: object

Represents a remote repository.

Parameters
  • style (str) – The style of remote.

  • domain (str) – The domain of the remote.

  • repo (str) – The repository the remote points to.

  • username (str) – The account on the remote server which owns the repository.

Methods:

as_url()

Returns the apeye.url.URL representation of the :class;`~.Remote`.

from_url(url)

Construct a Remote from a url.

set_repo(repo)

If repo is not None, set repo to that value.

set_username(username)

If username is not None, set username to that value.

Attributes:

domain

The domain of the remote.

repo

The repository the remote points to.

style

The style of remote.

username

The account on the remote server which owns the repository.

as_url()[source]

Returns the apeye.url.URL representation of the :class;`~.Remote`.

Return type

URL

Returns

domain

Type:    str

The domain of the remote.

classmethod from_url(url)[source]

Construct a Remote from a url.

Parameters

url (Union[str, URL])

Return type

Remote

repo

Type:    str

The repository the remote points to.

set_repo(repo)[source]

If repo is not None, set repo to that value.

Parameters

repo (Optional[str])

Returns

The new value of repo

set_username(username)[source]

If username is not None, set username to that value.

Parameters

username (Optional[str])

Returns

The new value of username

style

Type:    Literal['https', 'ssh']

The style of remote.

username

Type:    str

The account on the remote server which owns the repository.

class Toggler(repo, *args, **kwargs)[source]

Bases: Repo

Toggle Git remotes between https and ssh.

Parameters

repo (Union[Repo, str, Path, PathLike]) – The repository to toggle remotes for.

Methods:

get_current_remote([name])

Return the current remote.

set_current_remote(url[, name])

Set the current remote.

get_current_remote(name='origin')[source]

Return the current remote.

Parameters

name (str) – If given, try to retrieve the remote with that name. If no such remote exists returns the origin remote. Default 'origin'.

If no remote can be found an empty string will be returned.

Return type

str

set_current_remote(url, name='origin')[source]

Set the current remote.

Parameters
  • url (Union[str, URL, Remote]) – The URL to set for the remote.

  • name (str) – The name of the remote to set. Default 'origin'.