pre-commit-golang icon indicating copy to clipboard operation
pre-commit-golang copied to clipboard

feat: Support Environment Variables for Hook Commands

Open TekWizely opened this issue 3 years ago • 0 comments

Adds ability to configure environment variables to be set when invoking hook commands. Variables are configured via hook "args" using the following argument pattern:

--hook:env:NAME=VALUE

feat: Add support for "--hook:error-on-output" in my-cmd-* hooks.

  • Can exist anywhere in the arg list before a '--' argument
  • re: Support for plain '--error-on-output' at first element
    • Still works (currently)
    • Is now deprecated and will be removed in a future version

chore: Use "/usr/bin/env" to invoke commands

  • No-longer invokes the commands directly
  • Makes it trivial to pass environment variables to commands
  • Should not cause issues as /usr/bin/env was already vital

chore: Add "shellcheck source" declarations on dynamically sourced files

  • Only files that were already modified for this PR were addressed

Breaking Change: For compatibility with file-based hooks, Repo-based hooks no-longer ignore '--', or proceeding arguments, in the argument list. However, to further match file-based logic, the first '--' will be consumed, treating anything after it as OPTIONS to be passed to the hook command.


TODOS:
  • [ ] Update Docs

replaces #25

cc: @timuralp

TekWizely avatar Oct 14 '22 21:10 TekWizely