Installs packaged Git hooks for the consumer repository.
'git-hooks'
'Installs Fast Forward Git hooks.'
'This command copies packaged Git hooks into the current repository.'
Interfaces
Defines the logger contract consumed by reusable command result helpers.
Properties
Methods
Creates a new GitHooksCommand instance.
Adds the standard JSON output options to the current command.
Configures hook source, target, and initialization options.
Copies packaged Git hooks.
Determines whether JSON output was requested.
Determines whether pretty JSON output was requested.
Logs a failed command result and returns the failure exit code.
Logs an informational command message at notice level.
Prompts whether a drifted hook should be replaced.
Logs a successful command result and returns the success exit code.
private
FileDiffer
$fileDiffer
private
FileLocatorInterface
$fileLocator
private
FilesystemInterface
$filesystem
private
FinderFactoryInterface
$finderFactory
private
LoggerInterface
$logger
Creates a new GitHooksCommand instance.
public
__construct(FilesystemInterface
$filesystem, FileLocatorInterface
$fileLocator, FinderFactoryInterface
$finderFactory, FileDiffer
$fileDiffer, LoggerInterface
$logger) : mixed
Parameters
Description
the filesystem used to copy hooks
$fileLocator
:
FileLocatorInterface
Description
the locator used to find packaged hooks
Description
the factory used to create finders for hook files
$logger
:
LoggerInterface
Description
the output-aware logger
Adds the standard JSON output options to the current command.
protected
addJsonOption() : static
Return values
Configures hook source, target, and initialization options.
protected
configure() : void
Copies packaged Git hooks.
protected
execute(InputInterface
$input, OutputInterface
$output) : int
Parameters
$input
:
InputInterface
Description
the command input
$output
:
OutputInterface
Description
the command output
Return values
Description
the command status code
Determines whether JSON output was requested.
protected
isJsonOutput(InputInterface
$input) : bool
Description
The pretty-json flag SHALL imply JSON output.
Parameters
$input
:
InputInterface
Return values
Determines whether pretty JSON output was requested.
protected
isPrettyJsonOutput(InputInterface
$input) : bool
Parameters
$input
:
InputInterface
Return values
Logs a failed command result and returns the failure exit code.
private
failure(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string|null
$file = null][,
int|null
$line = null]) : int
Parameters
$message
:
string
Description
the failure message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$file
:
string|null
=
null
Description
the related file path when known
$line
:
int|null
=
null
Description
the related line when known
Return values
Logs an informational command message at notice level.
private
notice(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []]) : void
Parameters
$message
:
string
Description
the notice message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
Prompts whether a drifted hook should be replaced.
private
shouldReplaceHook(
string
$hookPath) : bool
Parameters
$hookPath
:
string
Description
the hook path that would be replaced
Return values
Description
true when the replacement SHOULD proceed
Logs a successful command result and returns the success exit code.
private
success(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string
$logLevel = LogLevel::INFO]) : int
Parameters
$message
:
string
Description
the success message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$logLevel
:
string
=
LogLevel::INFO
Description
the PSR-3 log level used for the successful result