Git.Commands.Maintenance (git v0.4.0)

Copy Markdown View Source

Implements the Git.Command behaviour for git maintenance.

Runs, starts, stops, registers, or unregisters repository maintenance tasks such as garbage collection, commit-graph updates, and prefetching.

Summary

Functions

Returns the argument list for git maintenance.

Parses the output of git maintenance.

Types

t()

@type t() :: %Git.Commands.Maintenance{
  auto: boolean(),
  quiet: boolean(),
  register_: boolean(),
  run: boolean(),
  schedule: String.t() | nil,
  start: boolean(),
  stop: boolean(),
  task: String.t() | nil,
  unregister: boolean()
}

Functions

args(command)

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

Returns the argument list for git maintenance.

Examples

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{run: true})
["maintenance", "run"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{start: true})
["maintenance", "start"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{stop: true})
["maintenance", "stop"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{register_: true})
["maintenance", "register"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{unregister: true})
["maintenance", "unregister"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{run: true, task: "gc"})
["maintenance", "run", "--task", "gc"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{run: true, auto: true})
["maintenance", "run", "--auto"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{run: true, quiet: true})
["maintenance", "run", "--quiet"]

iex> Git.Commands.Maintenance.args(%Git.Commands.Maintenance{run: true, schedule: "daily"})
["maintenance", "run", "--schedule", "daily"]

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 maintenance.

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