View Source GitHooks.Tasks.Cmd (git_hooks v0.7.3)
Represents a command that will be executed as a git hook task.
A command should be configured as {:cmd, command, opts}
, being opts
an
optional configuration.
For example:
config :git_hooks,
hooks: [
pre_commit: [
{:cmd, "ls -lisa", include_hook_args: true}
]
]
Link to this section Summary
Functions
Creates a new cmd
struct that will execute a command.
Link to this section Types
Link to this section Functions
@spec new( {:cmd, command :: String.t(), [any()]}, GitHooks.git_hook_type(), GitHooks.git_hook_args() ) :: t()
Creates a new cmd
struct that will execute a command.
This function expects a tuple or triple with :cmd
, the command to execute
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.Cmd.new({:cmd, "ls -l", env: [{"var", "test"}], include_hook_args: true}, :pre_commit, ["commit message"])
%Elixir.GitHooks.Tasks.Cmd{command: "ls", original_command: "ls -l", args: ["-l", "commit message"], env: [{"var", "test"}], git_hook_type: :pre_commit}
iex> Elixir.GitHooks.Tasks.Cmd.new({:cmd, "ls", include_hook_args: false}, :pre_commit, ["commit message"])
%Elixir.GitHooks.Tasks.Cmd{command: "ls", original_command: "ls", args: [], env: [], git_hook_type: :pre_commit}