/** * @param ChangeInfoEnvelope|UntrackedChangeInfo $changeInfo * @param string $fullAction * @return bool * @throws \Exception */ public static function containsAction($changeInfo, $fullAction) { if ($changeInfo instanceof ChangeInfoEnvelope) { $changeInfos = $changeInfo->getChangeInfoList(); foreach ($changeInfos as $ci) { if (self::getFullAction($ci) == $fullAction) { return true; } } return false; } else { throw new \Exception("Only ChangeInfoEnvelopes are supported"); } }
/** * 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); } }