Skip to content

Commit

Permalink
fix setting organization
Browse files Browse the repository at this point in the history
  • Loading branch information
smisidjan committed Nov 9, 2023
1 parent 93bd6bb commit 7d596e6
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/Service/FindGithubRepositoryThroughOrganizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,30 +234,25 @@ public function getOrganisationRepo(string $url, ObjectEntity $organization, str

$name = trim(\Safe\parse_url($url, PHP_URL_PATH), '/');

$this->pluginLogger->debug('Getting repo from organisation '.$name);
$response = $this->callService->call($source, '/repos/'.$name);

$repository = json_decode($response->getBody()->getContents(), true);
if ($repository === null) {
$this->pluginLogger->error('Could not find a repos from organisation with name: '.$name.' and with source: '.$source->getName());

return null;
}//end if
// Get the repository from the github api.
$repository = $this->githubApiService->getRepository($name, $source);

// import the repository and set the organisation.
$repositoryObject = $this->importResourcesService->importGithubRepository($repository, $this->configuration);

$repositoryObject->setValue('organisation', $organization);
$this->entityManager->persist($repositoryObject);
$this->entityManager->flush();

$sync = $this->syncService->findSyncBySource($source, $componentSchema, $repositoryObject->getValue('url'));
$this->syncService->synchronize($sync, ['name' => $repositoryObject->getValue('name'), 'url' => $repositoryObject]);
$sync = $this->syncService->synchronize($sync, ['name' => $repositoryObject->getValue('name'), 'url' => $repositoryObject]);

$this->pluginLogger->debug('Found repo from organisation with name: '.$name);

if ($type === 'use') {
$component = $repositoryObject->getValue('component');
$component && $component->setValue('usedBy', [$organization]);
$sync->getObject()->setValue('usedBy', [$organization]);
}

$repositoryObject->setValue('organisation', $organization);
$this->entityManager->persist($repositoryObject);
$this->entityManager->persist($sync->getObject());
$this->entityManager->flush();

return $repositoryObject;
Expand Down

0 comments on commit 7d596e6

Please sign in to comment.