Git.Commands.WriteTree (git v0.6.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git write-tree.

Records the current index as a tree object and returns its SHA. This is the plumbing counterpart to Git.Commands.CommitTree: write-tree produces the tree SHA that commit-tree turns into a commit, so together they build a commit without touching HEAD or the working tree.

Summary

Functions

Returns the argument list for git write-tree.

Parses the output of git write-tree.

Types

t()

@type t() :: %Git.Commands.WriteTree{missing_ok: boolean(), prefix: String.t() | nil}

Functions

args(command)

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

Returns the argument list for git write-tree.

Examples

iex> Git.Commands.WriteTree.args(%Git.Commands.WriteTree{})
["write-tree"]

iex> Git.Commands.WriteTree.args(%Git.Commands.WriteTree{prefix: "lib"})
["write-tree", "--prefix=lib"]

iex> Git.Commands.WriteTree.args(%Git.Commands.WriteTree{missing_ok: true})
["write-tree", "--missing-ok"]

parse_output(stdout, exit_code)

@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, String.t()} | {:error, {String.t(), non_neg_integer()}}

Parses the output of git write-tree.

On success (exit code 0), returns {:ok, sha} with the trimmed tree SHA. On failure, returns {:error, {stdout, exit_code}}.