Git.CherryEntry (git v0.4.0)

Copy Markdown View Source

Parsed representation of a git cherry output line.

Each entry indicates whether a commit has been applied upstream (cherry-picked) and includes the commit SHA and optionally the subject line when verbose mode is used.

Summary

Functions

Parses the output of git cherry into a list of Git.CherryEntry structs.

Types

t()

@type t() :: %Git.CherryEntry{
  applied: boolean(),
  sha: String.t(),
  subject: String.t() | nil
}

Functions

parse(output)

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

Parses the output of git cherry into a list of Git.CherryEntry structs.

Each line starts with + (not applied upstream) or - (already applied), followed by a SHA. With -v, a subject line follows the SHA.

Examples

iex> Git.CherryEntry.parse("+ abc1234\n- def5678\n")
[
  %Git.CherryEntry{applied: false, sha: "abc1234", subject: nil},
  %Git.CherryEntry{applied: true, sha: "def5678", subject: nil}
]

iex> Git.CherryEntry.parse("+ abc1234 add feature\n- def5678 fix bug\n")
[
  %Git.CherryEntry{applied: false, sha: "abc1234", subject: "add feature"},
  %Git.CherryEntry{applied: true, sha: "def5678", subject: "fix bug"}
]

iex> Git.CherryEntry.parse("")
[]