Implements the Git.Command behaviour for git ls-remote.
Lists references in a remote repository. Parses the output into
a list of Git.LsRemoteEntry structs containing the SHA and ref name.
Symref lines (from --symref) are included with sha set to nil.
Summary
Types
Functions
Returns the argument list for git ls-remote.
The remote name/URL is placed after flags. The refs pattern, if given, is appended at the end.
Examples
iex> Git.Commands.LsRemote.args(%Git.Commands.LsRemote{})
["ls-remote"]
iex> Git.Commands.LsRemote.args(%Git.Commands.LsRemote{heads: true, tags: true})
["ls-remote", "--heads", "--tags"]
iex> Git.Commands.LsRemote.args(%Git.Commands.LsRemote{remote: "origin", refs: "refs/heads/main"})
["ls-remote", "origin", "refs/heads/main"]
iex> Git.Commands.LsRemote.args(%Git.Commands.LsRemote{symref: true, sort: "version:refname"})
["ls-remote", "--symref", "--sort=version:refname"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [Git.LsRemoteEntry.t()]} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git ls-remote.
On success (exit code 0), parses tab-separated SHA\tref lines into
a list of Git.LsRemoteEntry structs. Symref lines (prefixed with
ref:) are included with sha set to nil.
Exit code 2 with --exit-code means no matching refs and returns
{:ok, []}.
Returns {:error, {stdout, exit_code}} on other failures.