Skip to content

Support for Environment Variables - v1.0.0-rc.1

Latest
Compare
Choose a tag to compare
@TekWizely TekWizely released this 31 Oct 20:55
· 1 commit to master since this release
302c7fd

Release v1.0.0-rc.1

Environment Variables

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

--hook:env:NAME=VALUE

The hook script will detect this argument and set the variable NAME to the value VALUE before invoking the configured tool.

You can pass multiple --hook:env: arguments.

The arguments can appear anywhere in the args: list (before an arg-terminating -- of course).

error-on-output

Previously, my-cmd-* hooks accepted a --error-on-output argument to signal when any output generated by the command should be treated as an error.

In order to try to minimize issues when using such a plain option, the option was required to be a the very first element of the args: list, ie.

args: [ --error-on-output, gofmt, -l, -d ]

This release adds additional support for a less-plain option:

  • --hook:error-on-output

This option, being less-likely to cause issues with existing tools, can exist anywhere in the args list (before an arg-terminating -- of course), ie.

args: [ gofmt, -l, -d, --hook:error-on-output]

NOTE: The plain --error-on-output at first element still works (currently), but is now deprecated and will be removed in a future version

Invoking hook commands

Now uses /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 for using this library

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.

Likely v1.0.0 Final

This release will likely become the official v1.0.0 release, but I'll give it a few weeks just in case recent changes added any bugs.