Git.Commands.Log (git v0.7.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: boolean(),
  all_match: boolean(),
  author: String.t() | nil,
  branches: boolean(),
  committer: String.t() | nil,
  extended_regexp: boolean(),
  first_parent: boolean(),
  fixed_strings: boolean(),
  follow: boolean(),
  grep: String.t() | nil,
  invert_grep: boolean(),
  max_count: non_neg_integer() | nil,
  merges: boolean(),
  no_merges: boolean(),
  path: String.t() | nil,
  perl_regexp: boolean(),
  pickaxe: String.t() | nil,
  pickaxe_regex: String.t() | nil,
  range: String.t() | nil,
  regexp_ignore_case: boolean(),
  reverse: boolean(),
  since: String.t() | nil,
  skip: non_neg_integer() | nil,
  tags: boolean(),
  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.

In addition to :max_count, :author, :since, :until_date, :grep, :pickaxe/:pickaxe_regex, :range, and :path, supports history controls that do not change the per-commit output format: :committer, :skip, :reverse, :follow, :no_merges/:merges, :first_parent, the grep modifiers :regexp_ignore_case (-i), :extended_regexp (-E), :fixed_strings (-F), :perl_regexp, :invert_grep, and the ref selectors :all, :branches, and :tags.

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.