gabyx / Githooks

🦎 Githooks: per-repo and shared Git hooks with version control and auto update. [✩Star] if you're using it!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduce number of hooks run over Githooks

gabyx opened this issue · comments

To reduce the number hooks run over Githooks, the user could modify them

git hooks config maintained-hooks [--local] [--global]   "-post-index-change" "-reference-transaction" # all + remove
git hooks config maintained-hooks [--local] [--global]   "-all" "pre-commit" "post-commit" "post-merge" # empty, add back

All commands will set the githooks.maintainedHooks variable either in local (set Ml) or global scope (set Mg) .
LFS related hooks can never be removed, only by githooks uninstall.

  • -/(+) determine whats included, all is the whole set.
  • predefined set server, all (for --local operation, all corresponds to server or non-server hooks)
  • --local: Updates the run wrappers inside the repository.
    • Warns if core.hooksPath is set.
  • --global : Updates the global run wrappers (init.temlateDir or core.hooksPath).
    • If not using core.hooksPath, asks if registered repos without a local overwrite Ml, should be updated, to reflect that change too, default yes.
  • Git LFS hooks can never be unset, they are always part.
  1. New installs will only read --global githooks.maintainedHooks (or legacy githooks.maintainOnlyServerHooks) and overiden by arguments --maintained-hooks values: server, all, [-]<hook-name>).

    1. It will set --global githooks.maintainedHooks.
    2. It will delete legacy githooks.maintainOnlyServerHooks in favor of the above.
    3. Run wrappers are set according to this set.
    4. Automatic installing into registered repositories -> see 3.
  2. Manual and auto-updates runs exactly as point 1.

  3. Local git hooks install will use first only --local githooks.maintainedHooks if set otherwise the global one is used, or default all (all hooks depending on bare/non-bare repo).

  4. Local git hooks uninstall will remove Githooks: iterate over all detected Githooks and deletes it and reinstalls replaced hooks (no LFS statements possible), and if git-lfs run git lfs install. All because, if the user changes the maintained hooks, when using Githooks, some repos might have another set, which complicates things.

Notes: -all == - (ManagedHookNames - LFSHookNames) and -server == - (ManagedServerHookNames - LFSHookNames)

PR #74
Implements this. Readme will come.
Another PR is neede to add CLI integeration.

For 1.i and 1.ii