Git.Commands.Shortlog (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git shortlog.

Summarizes git log output grouped by author. Supports summary mode (count only), numbered sorting, email display, and ref ranges.

Summary

Functions

Returns the argument list for git shortlog.

Parses the output of git shortlog.

Types

t()

@type t() :: %Git.Commands.Shortlog{
  all: boolean(),
  email: boolean(),
  group: String.t() | nil,
  max_count: non_neg_integer() | nil,
  numbered: boolean(),
  ref: String.t() | nil,
  since: String.t() | nil,
  summary: boolean(),
  until_date: String.t() | nil
}

Functions

args(command)

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

Returns the argument list for git shortlog.

Examples

iex> Git.Commands.Shortlog.args(%Git.Commands.Shortlog{})
["shortlog"]

iex> Git.Commands.Shortlog.args(%Git.Commands.Shortlog{summary: true, numbered: true})
["shortlog", "-s", "-n"]

iex> Git.Commands.Shortlog.args(%Git.Commands.Shortlog{email: true, ref: "v1.0..HEAD"})
["shortlog", "-e", "v1.0..HEAD"]

iex> Git.Commands.Shortlog.args(%Git.Commands.Shortlog{max_count: 10, group: "author"})
["shortlog", "--max-count=10", "--group=author"]

parse_output(stdout, exit_code)

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

Parses the output of git shortlog.

When summary mode is detected (tab-separated count and author), uses ShortlogEntry.parse_summary/1. Otherwise uses ShortlogEntry.parse_full/1.

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