Implements the Git.Command behaviour for git branch.
Supports listing branches (default), creating a new branch, and deleting
a branch. Branch listing uses -vv to include upstream tracking information.
Summary
Types
Functions
Returns the argument list for git branch.
- If
:createis set, buildsgit branch <name>. - If
:deleteis set, buildsgit branch -d <name>(or-Dwithforce_delete: true). - Otherwise, lists branches with
-vvand optionally--all.
Examples
iex> Git.Commands.Branch.args(%Git.Commands.Branch{})
["branch", "-vv"]
iex> Git.Commands.Branch.args(%Git.Commands.Branch{create: "feat/new"})
["branch", "feat/new"]
iex> Git.Commands.Branch.args(%Git.Commands.Branch{delete: "old", force_delete: true})
["branch", "-D", "old"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [Git.Branch.t()]} | {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git branch.
For list operations (exit 0), parses each line into a Git.Branch struct.
For create/delete operations (exit 0, empty output), returns {:ok, :done}.
On failure, returns {:error, {stdout, exit_code}}.