Provides functionality to manage .gitattributes export-ignore rules.
Description
This command adds export-ignore entries for repository-only files and directories to keep them out of Composer package archives.
'git:attributes'
'Manages .gitattributes export-ignore rules for leaner package archives.'
['.gitattributes', 'gitattributes']
Constants
Properties
Methods
Creates a new GitAttributesCommand instance.
Adds the standard JSON output options to the current command.
Configures verification and interactive update modes.
Configures the current command.
Determines whether JSON output was requested.
Determines whether pretty JSON output was requested.
Resolves the consumer-defined paths that MUST stay in exported archives.
Logs a failed command result and returns the failure exit code.
Determines whether structured JSON output SHOULD be enabled implicitly.
Determines whether a boolean input option was enabled.
Logs a non-terminal command message unless structured JSON output is active.
Prompts whether .gitattributes should be updated.
Logs a successful command result and returns the success exit code.
private
string
EXTRA_KEEP_IN_EXPORT
=
'keep-in-export'
private
string
EXTRA_NAMESPACE
=
'gitattributes'
private
string
EXTRA_NO_EXPORT_IGNORE
=
'no-export-ignore'
private
string
FILENAME
=
'.gitattributes'
private
CandidateProviderInterface
$candidateProvider
private
ComposerJsonInterface
$composer
private
ExistenceCheckerInterface
$existenceChecker
private
ExportIgnoreFilterInterface
$exportIgnoreFilter
private
FileDiffer
$fileDiffer
private
FilesystemInterface
$filesystem
private
SymfonyStyle
$io
private
MergerInterface
$merger
private
ReaderInterface
$reader
private
WriterInterface
$writer
Creates a new GitAttributesCommand instance.
public
__construct(CandidateProviderInterface
$candidateProvider, ExistenceCheckerInterface
$existenceChecker, ExportIgnoreFilterInterface
$exportIgnoreFilter, MergerInterface
$merger, ReaderInterface
$reader, WriterInterface
$writer, ComposerJsonInterface
$composer, FilesystemInterface
$filesystem, FileDiffer
$fileDiffer, SymfonyStyle
$io) : mixed
Parameters
Description
the candidate provider
Description
the repository path existence checker
Description
the configured candidate filter
Description
the merger component
Description
the reader component
Description
the writer component
Description
the composer.json accessor
Description
the filesystem component
Description
the file differ used to summarize synchronization changes
$io
:
SymfonyStyle
Description
the input/output service used to interact with the user
Adds the standard JSON output options to the current command.
protected
addJsonOption() : static
Return values
Configures verification and interactive update modes.
protected
configure() : void
Configures the current command.
protected
execute(InputInterface
$input, OutputInterface
$output) : int
Description
This method MUST define the name, description, and help text for the command.
Parameters
$input
:
InputInterface
$output
:
OutputInterface
Return values
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
Resolves the consumer-defined paths that MUST stay in exported archives.
private
configuredKeepInExportPaths() : array<int, string>
Description
The preferred configuration key is "extra.gitattributes.keep-in-export". The alternate "extra.gitattributes.no-export-ignore" key remains supported as a compatibility alias.
Return values
Description
the configured keep-in-export paths
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
Determines whether structured JSON output SHOULD be enabled implicitly.
private
isImplicitJsonOutputEnabled() : bool
Description
Commands MAY opt into runtime-environment-aware behavior by exposing a
$runtimeEnvironment property. Commands that do not expose it SHALL fall
back to the shared runtime-environment service from the DevTools container.
Return values
Determines whether a boolean input option was enabled.
private
isOptionEnabled(InputInterface
$input,
string
$option) : bool
Parameters
$input
:
InputInterface
$option
:
string
Return values
Logs a non-terminal command message unless structured JSON output is active.
private
log(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string
$logLevel = LogLevel::INFO]) : void
Parameters
$message
:
string
Description
the progress 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 message
private
resolveRuntimeEnvironment() : RuntimeEnvironmentInterface|null
Return values
Prompts whether .gitattributes should be updated.
private
shouldWriteGitAttributes(
string
$targetPath) : bool
Parameters
$targetPath
:
string
Description
the target path that would be updated
Return values
Description
true when the update 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