Which GitHub repository the working directory belongs to.
gitpro takes no repository argument in the usual case: you are standing in a
checkout, and that is the answer. So the directory is handed to git and the
origin remote it reports is parsed into an owner and a name.
Remotes come in more shapes than one:
git@github.com:owner/repo.git
ssh://git@github.com/owner/repo.git
https://github.com/owner/repo.git
https://user@github.com/owner/repoparse_remote/1 takes all of them, and is a pure function — the part worth
testing is the parsing, not the shelling out.
Summary
Functions
Turns a remote URL into {:ok, %{owner:, name:}}.
The URL of the origin remote of the repository at dir.
The repository the directory dir is a checkout of.
Types
Functions
Turns a remote URL into {:ok, %{owner:, name:}}.
The .git suffix is optional, the scheme may be missing, and any user
information in front of the host is ignored — what matters is the last two
path segments of a github.com URL.
The URL of the origin remote of the repository at dir.
The repository the directory dir is a checkout of.
Answers {:error, message} rather than raising: a message that can be printed
before the UI starts is more use than a stack trace, and every way this fails
— not a repository, no remote, a remote that is not GitHub — is something the
person at the keyboard can act on.