Git.Commands.Log (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git log.

Builds arguments for the git log subcommand and parses the output into a list of Git.Commit structs.

Summary

Functions

Builds the argument list for git log.

Parses the stdout and exit code from git log into a result.

Types

t()

@type t() :: %Git.Commands.Log{
  all_match: boolean(),
  author: String.t() | nil,
  grep: String.t() | nil,
  max_count: non_neg_integer() | nil,
  path: String.t() | nil,
  pickaxe: String.t() | nil,
  pickaxe_regex: String.t() | nil,
  range: String.t() | nil,
  since: String.t() | nil,
  until_date: String.t() | nil
}

Functions

args(command)

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

Builds the argument list for git log.

Uses ASCII control characters as delimiters to reliably parse output even when commit messages contain newlines or special characters.

parse_output(stdout, exit_code)

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

Parses the stdout and exit code from git log into a result.

Returns {:ok, [%Git.Commit{}]} on success or {:error, {stdout, exit_code}} on failure.