Git.Tag (git v0.4.0)

Copy Markdown View Source

Parsed representation of a git tag.

Contains the tag name, whether it is annotated, the tagger name and email (for annotated tags), the date, and the annotation message.

Summary

Functions

Returns the --format string used by git tag -l for detailed output.

Parses the output of git tag -l --format=... with the detailed format string.

Parses the output of git tag -l -n1 into a list of Git.Tag structs.

Types

t()

@type t() :: %Git.Tag{
  annotated: boolean(),
  date: String.t() | nil,
  message: String.t() | nil,
  name: String.t(),
  tagger_email: String.t() | nil,
  tagger_name: String.t() | nil
}

Functions

format_string()

@spec format_string() :: String.t()

Returns the --format string used by git tag -l for detailed output.

Uses ASCII control characters as delimiters for reliable parsing.

parse_detailed(output)

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

Parses the output of git tag -l --format=... with the detailed format string.

Examples

iex> Git.Tag.parse_detailed("")
[]

parse_list(output)

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

Parses the output of git tag -l -n1 into a list of Git.Tag structs.

Each line has the form:

v1.0.0          first release
v1.1.0          second release

Tags with an annotation message are marked as annotated. Lightweight tags have no message in -n1 output (or the message matches the commit subject).

Examples

iex> Git.Tag.parse_list("v1.0.0\nv1.1.0\n")
[%Git.Tag{name: "v1.0.0", annotated: false}, %Git.Tag{name: "v1.1.0", annotated: false}]