Git.Remote (git v0.4.0)

Copy Markdown View Source

Represents a git remote with its name, fetch URL, and push URL.

Parsed from git remote -v output via parse_verbose/1.

Summary

Functions

Parses the output of git remote -v into a list of %Git.Remote{} structs.

Types

t()

@type t() :: %Git.Remote{
  fetch_url: String.t() | nil,
  name: String.t(),
  push_url: String.t() | nil
}

Functions

parse_verbose(output)

@spec parse_verbose(String.t()) :: [t()]

Parses the output of git remote -v into a list of %Git.Remote{} structs.

Each remote appears twice in the output (once for fetch, once for push). Lines are grouped by remote name so each remote becomes a single struct.

Examples

iex> output = "origin\thttps://github.com/user/repo.git (fetch)\norigin\thttps://github.com/user/repo.git (push)\n"
iex> Git.Remote.parse_verbose(output)
[%Git.Remote{name: "origin", fetch_url: "https://github.com/user/repo.git", push_url: "https://github.com/user/repo.git"}]