GitHoox.Installer (GitHoox v0.1.0)

Copy Markdown View Source

Manage .git/hooks/* shim files.

Refuses to overwrite user-authored hooks. Pass force: true to back up and replace. Detects own shims by # git_hoox managed marker.

Summary

Functions

Install hook shims into .git/hooks/.

Write a starter .git_hoox.exs at the repo root.

Remove managed shims. Restore latest backup if present.

Types

action()

@type action() :: :write | :overwrite_managed | :overwrite_with_backup

Per-hook installer plan entry.

install_error()

@type install_error() :: :not_a_git_repo | {:exists, Path.t(), String.t()}

plan_entry()

@type plan_entry() :: {String.t(), Path.t(), action()}

scaffold_error()

@type scaffold_error() :: {:config_exists, Path.t()}

Functions

install(opts \\ [])

@spec install(keyword()) :: {:ok, [plan_entry()]} | {:error, install_error()}

Install hook shims into .git/hooks/.

Options

  • :force — overwrite user hooks with backup. Default false.
  • :dry_run — print plan, no writes. Default false.

scaffold(opts \\ [])

@spec scaffold(keyword()) :: {:ok, Path.t()} | {:error, scaffold_error()}

Write a starter .git_hoox.exs at the repo root.

Options

  • :force — overwrite existing config. Default false.

Returns {:ok, path} on success or {:error, {:config_exists, path}} if the file already exists and :force is false.

uninstall(opts \\ [])

@spec uninstall(keyword()) :: {:ok, non_neg_integer()}

Remove managed shims. Restore latest backup if present.