Implements the Git.Command behaviour for git format-patch.
Generates patch files from commits. Supports output to files or stdout, cover letters, numbering, and various patch formatting options.
Summary
Types
@type t() :: %Git.Commands.FormatPatch{ base: String.t() | nil, cover_letter: boolean(), from: String.t() | nil, no_signature: boolean(), no_stat: boolean(), numbered: boolean(), output_directory: String.t() | nil, quiet: boolean(), ref: String.t(), signature: String.t() | nil, start_number: non_neg_integer() | nil, stdout: boolean(), subject_prefix: String.t() | nil, zero_commit: boolean() }
Functions
Returns the argument list for git format-patch.
Examples
iex> Git.Commands.FormatPatch.args(%Git.Commands.FormatPatch{ref: "HEAD~3"})
["format-patch", "HEAD~3"]
iex> Git.Commands.FormatPatch.args(%Git.Commands.FormatPatch{ref: "HEAD~1", stdout: true})
["format-patch", "--stdout", "HEAD~1"]
iex> Git.Commands.FormatPatch.args(%Git.Commands.FormatPatch{ref: "v1.0..v2.0", output_directory: "/tmp/patches", numbered: true})
["format-patch", "-n", "-o", "/tmp/patches", "v1.0..v2.0"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, String.t()} | {:ok, [String.t()]} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git format-patch.
When stdout mode is active, returns {:ok, patch_content}.
Otherwise, returns {:ok, [file_path]} with the list of generated
patch file paths.
On failure, returns {:error, {stdout, exit_code}}.