Implements the Git.Command behaviour for git notes.
Supports listing notes, showing a note for a specific ref, adding notes, appending to existing notes, removing notes, and pruning notes for unreachable objects.
Edit mode (git notes edit) is intentionally not supported because it
launches an interactive editor which cannot be driven programmatically.
Summary
Types
Functions
Returns the argument list for git notes.
Examples
iex> Git.Commands.Notes.args(%Git.Commands.Notes{})
["notes", "list"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{show: "HEAD"})
["notes", "show", "HEAD"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{add: true, message: "my note", ref: "HEAD"})
["notes", "add", "-m", "my note", "HEAD"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{add: true, message: "note", ref: "HEAD", force: true})
["notes", "add", "-f", "-m", "note", "HEAD"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{append: true, message: "more", ref: "HEAD"})
["notes", "append", "-m", "more", "HEAD"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{remove: "HEAD"})
["notes", "remove", "HEAD"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{prune: true})
["notes", "prune"]
iex> Git.Commands.Notes.args(%Git.Commands.Notes{notes_ref: "custom"})
["notes", "--ref=custom", "list"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [map()]} | {:ok, String.t()} | {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git notes.
- For
:listmode, parses lines of "note_sha commit_sha" into a list of maps. - For
:showmode, returns the note content as a string. - For mutation modes (add, append, remove, prune), returns
{:ok, :done}.