GitHooks.Tasks.File (git_hooks v0.6.4) View Source

Represents a file that will be executed as a git hook task.

A file should be configured as {:file, file_path, opts}, being opts an optional configuration. The file should be readable and have execution permissions.

See for more information.

For example:

config :git_hooks,
  hooks: [
    pre_commit: [
      {:file, "opt/scripts/checks", include_hook_args: true}

Link to this section Summary



Represents a file to be executed.

Link to this section Types


t() :: %GitHooks.Tasks.File{
  args: [any()],
  env: [{String.t(), String.t()}],
  file_path: String.t(),
  git_hook_type: atom(),
  result: term()

Represents a file to be executed.

Link to this section Functions

Link to this function

new(arg, git_hook_type, git_hook_args)

View Source


  {:file, path :: String.t(), [any()]},
) :: t()

Creates a new file struct.

This function expects a tuple or triple with :file, the file path and the opts.


  • include_hook_args: Whether the git options will be passed as argument when executing the file. You will need to check which arguments are being sent by each git hook.
  • env: The environment variables that will be set in the execution context of the file.


iex>{:file, :test, env: [{"var", "test"}], include_hook_args: true}, :pre_commit, ["commit message"])
%Elixir.GitHooks.Tasks.File{file_path: :test, args: ["commit message"], env: [{"var", "test"}], git_hook_type: :pre_commit}

iex>{:file, :test, include_hook_args: false}, :pre_commit, ["commit message"])
%Elixir.GitHooks.Tasks.File{file_path: :test, args: [], env: [], git_hook_type: :pre_commit}