Git.Version (git v0.7.0)

Copy Markdown View Source

Parsed representation of the installed git version.

Holds the numeric major, minor, and patch components along with the full raw version line as reported by git --version.

Summary

Functions

Parses the output of git --version into a Git.Version struct.

Types

t()

@type t() :: %Git.Version{
  major: non_neg_integer(),
  minor: non_neg_integer(),
  patch: non_neg_integer(),
  raw: String.t()
}

Functions

parse(output)

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

Parses the output of git --version into a Git.Version struct.

The version number is the third whitespace-delimited field. Its first three dot-separated numeric components become major, minor, and patch; any missing component defaults to 0. The full trimmed line is kept in raw.

Examples

iex> Git.Version.parse("git version 2.50.1 (Apple Git-155)\n")
%Git.Version{major: 2, minor: 50, patch: 1, raw: "git version 2.50.1 (Apple Git-155)"}

iex> Git.Version.parse("git version 2.42.0.windows.2")
%Git.Version{major: 2, minor: 42, patch: 0, raw: "git version 2.42.0.windows.2"}