Skip to content

Auto-upgrade stale hooks on partio enable #176

@jcleira

Description

@jcleira

Problem

When a user upgrades the Partio CLI binary, the git hook scripts installed in their repositories become stale — they may reference old binary paths, use outdated shim logic, or miss new hooks added in later versions. Currently, partio enable short-circuits entirely when .partio/ exists (cmd/partio/enable.go:38-42), telling the user "partio is already enabled" without checking whether the installed hooks are up to date.

The only workaround is partio disable && partio enable, which users must know to do and which unnecessarily tears down and rebuilds state.

Desired behavior

partio enable should detect stale hooks and silently upgrade them:

  1. If .partio/ exists, skip directory/config creation but still check hooks.
  2. For each expected hook (pre-commit, post-commit, pre-push), read the installed script from the hooks directory.
  3. Compare the installed content against the expected content from hookScript() / hookScriptAbsolute().
  4. If the content differs, overwrite the hook file (preserving the existing backup chain).
  5. If a hook is missing entirely, install it following the normal backup logic.
  6. Print a summary of what was upgraded.

Context

  • cmd/partio/enable.go — the .partio/ existence check that needs to be relaxed
  • internal/git/hooks/install.goinstallHooks() needs an upgrade-aware code path
  • internal/git/hooks/hooks.gohookScript() / hookScriptAbsolute() generate expected content

Source

Inspired by entireio/cli PR #775 — rewrite hook content when it differs from expected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions