Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
/**
* Commit Comment Command
*/
class CommitCommentCommand extends BuildToolsBase
class CommentAddCommitCommand extends BuildToolsBase
{

/**
* Add a comment to the latest commit on the repository.
*
* @authorize
*
* @command build:commit:comment
* @command build:comment:add:commit
*/
public function commitComment(
public function commentAddCommit(
$options = [
'message' => '',
'site_url' => ''
Expand Down
18 changes: 12 additions & 6 deletions src/Commands/EnvCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ class EnvCreateCommand extends BuildToolsBase
* @option label What to name the environment in commit comments
* @option clone-content Run terminus env:clone-content if the environment is re-used
* @option db-only Only clone the database when runing env:clone-content
* @option notify Command to exec to notify when a build environment is created
* @option notify Do not use this deprecated option. Previously used for a build notify command, currently ignored.
*/
public function createBuildEnv(
$site_env_id,
$multidev,
$options = [
'label' => '',
'clone-content' => false,
'db-only' => false,
'notify' => '',
'db-only' => false
])
{
list($site, $env) = $this->getSiteEnv($site_env_id);
Expand All @@ -60,6 +60,8 @@ public function createBuildEnv(
$env_label = $options['label'];
}

$doNotify = false;

// Fetch the site id also
$siteInfo = $site->serialize();
$site_id = $siteInfo['id'];
Expand All @@ -80,6 +82,7 @@ public function createBuildEnv(
// To allow pantheon.yml to be processed, we will
// create the multidev environment, and then push the code.
$this->create($site_env_id, $multidev);
$doNotify = true;
}

$metadata = $this->pushCodeToPantheon($site_env_id, $multidev, '', $env_label);
Expand All @@ -90,6 +93,7 @@ public function createBuildEnv(
// then there is never a race condition -- the new env is
// created with the correct files from the specified branch.
$this->create($site_env_id, $multidev);
$doNotify = true;
}

// Clear the environments, so that they will be re-fetched.
Expand Down Expand Up @@ -122,8 +126,10 @@ public function createBuildEnv(
// Set the target environment to sftp mode
$this->connectionSet($target, 'sftp');

// If '--notify' was passed, then exec the notify command
if (!empty($options['notify'])) {
// TODO: Push to repo provider

// Run notification command
if ($doNotify == true) {
$site_name = $site->getName();
$project = $this->projectFromRemoteUrl($metadata['url']);
$metadata += [
Expand All @@ -136,8 +142,8 @@ public function createBuildEnv(
'site-url' => "https://{$multidev}-{$site_name}.pantheonsite.io/",
];

$command = $this->interpolate($options['notify'], $metadata);

$command = $this->interpolate('terminus build:comment:add:commit --message [[label]] --site_url "[[site-url]]"', $metadata);
// Run notification command. Ignore errors.
passthru($command);
}
Expand Down