GitHooks.Tasks.Cmd.new

You're seeing just the function new, go back to GitHooks.Tasks.Cmd module for more information.
Link to this function

new(arg, git_hook_type, git_hook_args)

View Source

Specs

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

  • 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

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}