/** * Calls Git `add -A` on files that are related to the given $changeInfo. * The "exchange format" is an array documented in {@see TrackedChangedInfo::getChangedFiles()}. * * @param TrackedChangeInfo|ChangeInfoEnvelope $changeInfo */ private function stageRelatedFiles($changeInfo) { if ($changeInfo instanceof ChangeInfoEnvelope) { /** @var TrackedChangeInfo $subChangeInfo */ foreach ($changeInfo->getChangeInfoList() as $subChangeInfo) { $this->stageRelatedFiles($subChangeInfo); } return; } $changes = $changeInfo->getChangedFiles(); foreach ($changes as $change) { if ($change["type"] === "storage-file") { $entityName = $change["entity"]; $entityId = $change["id"]; $parentId = $change["parent-id"]; $path = $this->storageFactory->getStorage($entityName)->getEntityFilename($entityId, $parentId); } elseif ($change["type"] === "all-storage-files") { $entityName = $change["entity"]; $path = $this->storageFactory->getStorage($entityName)->getPathCommonToAllEntities(); } elseif ($change["type"] === "path") { $path = $change["path"]; } else { continue; } $this->repository->stageAll($path); } }
public function getChangedFiles() { $change = ["type" => "storage-file", "entity" => $this->getScope(), "id" => $this->getId(), "parent-id" => $this->getParentId()]; return array_merge([$change], parent::getChangedFiles()); }