Git.Commands.Gc (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git gc.

Cleans up unnecessary files and optimizes the local repository.

Summary

Functions

Returns the argument list for git gc.

Parses the output of git gc.

Types

t()

@type t() :: %Git.Commands.Gc{
  aggressive: boolean(),
  auto: boolean(),
  force: boolean(),
  keep_largest_pack: boolean(),
  no_prune: boolean(),
  prune: String.t() | nil,
  quiet: boolean()
}

Functions

args(command)

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

Returns the argument list for git gc.

Examples

iex> Git.Commands.Gc.args(%Git.Commands.Gc{})
["gc"]

iex> Git.Commands.Gc.args(%Git.Commands.Gc{aggressive: true})
["gc", "--aggressive"]

iex> Git.Commands.Gc.args(%Git.Commands.Gc{auto: true})
["gc", "--auto"]

iex> Git.Commands.Gc.args(%Git.Commands.Gc{prune: "now"})
["gc", "--prune=now"]

iex> Git.Commands.Gc.args(%Git.Commands.Gc{no_prune: true})
["gc", "--no-prune"]

iex> Git.Commands.Gc.args(%Git.Commands.Gc{quiet: true, force: true})
["gc", "--quiet", "--force"]

iex> Git.Commands.Gc.args(%Git.Commands.Gc{keep_largest_pack: true})
["gc", "--keep-largest-pack"]

parse_output(stdout, exit_code)

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

Parses the output of git gc.

On success (exit code 0), returns {:ok, :done}. On failure, returns {:error, {stdout, exit_code}}.