-
-
Notifications
You must be signed in to change notification settings - Fork 0
Merger
Merges, deduplicates, and sorts .gitignore entries.
This service SHALL combine canonical and project-specific .gitignore definitions into a single normalized result. The resulting entry list MUST exclude blank lines and comment lines from the merged output, MUST remove duplicate entries, and MUST group directory entries before file entries. Directory and file groups SHALL be sorted independently in ascending string order to provide deterministic output.
- Full name:
\FastForward\DevTools\GitIgnore\Merger - This class is marked as final and can't be subclassed
- This class implements:
\FastForward\DevTools\GitIgnore\MergerInterface - This class is a Final class
Initializes the merger with a classifier implementation.
public __construct(\FastForward\DevTools\GitIgnore\ClassifierInterface $classifier = new \FastForward\DevTools\GitIgnore\Classifier()): mixedThe classifier MUST be capable of determining whether a normalized .gitignore entry represents a directory or a file pattern. When no classifier is provided, a default Classifier instance SHALL be used.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$classifier |
\FastForward\DevTools\GitIgnore\ClassifierInterface | the classifier responsible for |
| distinguishing directory entries | ||
| from file entries during merging |
Merges canonical and project .gitignore entries into a normalized result.
public merge(\FastForward\DevTools\GitIgnore\GitIgnoreInterface $canonical, \FastForward\DevTools\GitIgnore\GitIgnoreInterface $project): \FastForward\DevTools\GitIgnore\GitIgnoreInterfaceThe implementation MUST combine entries from both sources, MUST remove duplicates, and MUST ignore blank or commented entries after trimming. Entries identified as directories SHALL be collected separately from file entries. Each group MUST be sorted using string comparison, and directory entries MUST appear before file entries in the final result.
The returned GitIgnore instance SHALL preserve the project path provided by the $project argument.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$canonical |
\FastForward\DevTools\GitIgnore\GitIgnoreInterface | The canonical .gitignore source whose |
| entries provide the shared baseline. | ||
$project |
\FastForward\DevTools\GitIgnore\GitIgnoreInterface | The project-specific .gitignore source |
| whose path MUST be preserved in the | ||
| merged result. |
Return Value:
A new merged .gitignore representation containing normalized, deduplicated, and ordered entries.