Git.Commands.Bundle (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git bundle.

Supports creating, verifying, listing heads of, and unbundling git bundles. Uses the process dictionary to communicate the operation mode from args/1 to parse_output/2.

Summary

Functions

Returns the argument list for git bundle.

Parses the output of git bundle.

Types

t()

@type t() :: %Git.Commands.Bundle{
  all: boolean(),
  create: String.t() | nil,
  list_heads: String.t() | nil,
  progress: boolean(),
  quiet: boolean(),
  rev: String.t() | nil,
  unbundle: String.t() | nil,
  verify: String.t() | nil
}

Functions

args(command)

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

Returns the argument list for git bundle.

Examples

iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{create: "/tmp/test.bundle", rev: "HEAD"})
["bundle", "create", "/tmp/test.bundle", "HEAD"]

iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{create: "/tmp/test.bundle", all: true})
["bundle", "create", "/tmp/test.bundle", "--all"]

iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{verify: "/tmp/test.bundle"})
["bundle", "verify", "/tmp/test.bundle"]

iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{list_heads: "/tmp/test.bundle"})
["bundle", "list-heads", "/tmp/test.bundle"]

iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{unbundle: "/tmp/test.bundle"})
["bundle", "unbundle", "/tmp/test.bundle"]

iex> Git.Commands.Bundle.args(%Git.Commands.Bundle{create: "/tmp/test.bundle", rev: "HEAD", quiet: true})
["bundle", "create", "-q", "/tmp/test.bundle", "HEAD"]

parse_output(stdout, exit_code)

@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, term()} | {:error, {String.t(), non_neg_integer()}}

Parses the output of git bundle.

  • create (exit 0): {:ok, :done}
  • verify (exit 0): {:ok, %{valid: true, raw: stdout}}
  • verify (exit 1): {:ok, %{valid: false, raw: stdout}}
  • list-heads (exit 0): {:ok, [%{sha: String.t(), ref: String.t()}]}
  • unbundle (exit 0): {:ok, :done}