Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions src/Commands/RepositorySiteCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function create($site_name, $label, $upstream_id, $options = [
'vcs' => 'github',
'installation_id' => null,
'visibility' => 'private',
'create-repo' => true,
])
{

Expand Down Expand Up @@ -245,7 +246,7 @@ public function create($site_name, $label, $upstream_id, $options = [
$repo_create_data = [
'site_uuid' => $site_uuid,
'label' => $site_name,
'skip_create' => false,
'skip_create' => $options['create-repo'] === false,
'is_private' => $options['visibility'] === 'private',
'vendor_id' => $vcs_id,
];
Expand Down Expand Up @@ -300,24 +301,26 @@ public function create($site_name, $label, $upstream_id, $options = [
);
}

// Call pantheonapi vcs/v1/repo-initialize.
$repo_initialize_data = [
'site_id' => $site_uuid,
'target_repo_url' => $target_repo_url,
'upstream_repo_url' => $upstream_repo_url,
'upstream_repo_branch' => $upstream_repo_branch,
'installation_id' => (string) $installation_id,
'organization_id' => $org->id,
];
if ($options['create-repo']) {
// Call pantheonapi vcs/v1/repo-initialize.
$repo_initialize_data = [
'site_id' => $site_uuid,
'target_repo_url' => $target_repo_url,
'upstream_repo_url' => $upstream_repo_url,
'upstream_repo_branch' => $upstream_repo_branch,
'installation_id' => (string) $installation_id,
'organization_id' => $org->id,
];

try {
$this->getVcsClient()->repoInitialize($repo_initialize_data);
} catch (\Throwable $t) {
$this->cleanup($site_uuid);
throw new TerminusException(
'Error initializing repo with contents: {error_message}',
['error_message' => $t->getMessage()]
);
try {
$this->getVcsClient()->repoInitialize($repo_initialize_data);
} catch (\Throwable $t) {
$this->cleanup($site_uuid);
throw new TerminusException(
'Error initializing repo with contents: {error_message}',
['error_message' => $t->getMessage()]
);
}
}

$this->log()->notice(sprintf("Site was correctly created, you can access your repo at %s", $target_repo_url));
Expand Down
Loading