Git.Commands.Remote (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git remote.

Supports listing remotes (with or without verbose URL output), adding a new remote, and removing an existing remote.

Summary

Functions

Builds the argument list for git remote.

Parses stdout and exit code from git remote into a result.

Types

t()

@type t() :: %Git.Commands.Remote{
  add_name: String.t() | nil,
  add_url: String.t() | nil,
  list: boolean(),
  remove: String.t() | nil,
  verbose: boolean()
}

Functions

args(remote)

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

Builds the argument list for git remote.

  • If add_name is set (with add_url): produces ["remote", "add", name, url]
  • If remove is set: produces ["remote", "remove", name]
  • Otherwise (list mode): produces ["remote"], plus "-v" when verbose: true

parse_output(stdout, exit_code)

@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, [Git.Remote.t()]}
  | {:ok, :done}
  | {:error, {String.t(), non_neg_integer()}}

Parses stdout and exit code from git remote into a result.

  • List with exit code 0: {:ok, [%Git.Remote{}]} (empty list when no remotes)
  • Add/remove with exit code 0: {:ok, :done}
  • Non-zero exit code: {:error, {stdout, exit_code}}