Git.Commands.Commit (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git commit.

Supports the -m (message), -a (all), --amend, and --allow-empty flags.

Summary

Functions

Returns the argument list for git commit.

Parses the output of git commit.

Types

t()

@type t() :: %Git.Commands.Commit{
  all: boolean(),
  allow_empty: boolean(),
  amend: boolean(),
  message: String.t()
}

Functions

args(command)

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

Returns the argument list for git commit.

Builds the argument list from the struct fields. The :message field is required and produces -m <message>. Optional flags are appended when set to true.

Examples

iex> args = Git.Commands.Commit.args(%Git.Commands.Commit{message: "test", all: true})
iex> args
["commit", "-m", "test", "-a"]

parse_output(stdout, exit_code)

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

Parses the output of git commit.

On success (exit code 0), parses the output into a Git.CommitResult struct. On failure, returns {:error, {stdout, exit_code}}.