repomatic.github.urls module¶
Read a GitHub repository out of the forms that name it.
A repository reaches this package in several spellings: the owner/name slug
of GITHUB_REPOSITORY, an HTTPS remote, an SSH remote, and a project_urls
entry that points into the repository rather than at it. This module is the one
reader of all of them, so every consumer derives the same (owner, name) pair
from the same input.
A leaf module with no project-internal imports, so any module can import it without the risk of an import cycle.
- repomatic.github.urls.GITHUB_REPO_RE = re.compile('(?:^|[/@])(?:www\\.)?github\\.com[:/]+(?P<owner>[^/\\s:?#]+)/(?P<name>[^/\\s?#]+)')¶
A repository on
github.com, in a URL or in a remote.The host must start the string or follow a
/(a URL scheme) or an@(an SSH user), so a host that only ends ingithub.comdoes not match, and neither doesapi.github.com, whose first path segment is not an owner. After the host comes a/in a URL, or a:in an SSH remote such asgit@github.com:owner/name.git. The match stops after the name, so a deep link likehttps://github.com/owner/name/issues/1reads as its repository.
- repomatic.github.urls.parse_github_repo(url)[source]¶
Read the
(owner, name)pair of the GitHub repository url points at.Accepts an HTTPS URL, an SSH remote (
git@github.com:owner/name.gitandssh://git@github.com/owner/name), and a deep link into the repository (https://github.com/owner/name/blob/main/readme.md). A trailing.git, slash, query or fragment is dropped.
