View Source GitHooks.Tasks.File (git_hooks v0.7.3)
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 Elixir.GitHooks.Tasks.File.new/1
for more information.
For example:
config :git_hooks,
hooks: [
pre_commit: [
{:file, "opt/scripts/checks", include_hook_args: true}
]
]
Link to this section Summary
Functions
Creates a new file
struct.
Link to this section Types
Link to this section Functions
@spec new( {:file, path :: String.t(), [any()]}, GitHooks.git_hook_type(), GitHooks.git_hook_args() ) :: t()
Creates a new file
struct.
This function expects a tuple or triple with :file
, the file path and
the opts.
options
Options
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.
examples
Examples
iex> Elixir.GitHooks.Tasks.File.new({: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> Elixir.GitHooks.Tasks.File.new({:file, :test, include_hook_args: false}, :pre_commit, ["commit message"])
%Elixir.GitHooks.Tasks.File{file_path: :test, args: [], env: [], git_hook_type: :pre_commit}