Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Commit f5ce565

Browse files
committed
Reformat VERSION.txt in YAML.
1 parent 08364c4 commit f5ce565

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

deployotron.actions.inc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Deployotron {
1818
'SiteOffline',
1919
'BackupDatabase',
2020
'DeployCode',
21-
'CreateVersionTxt',
21+
'CreateVersionYaml',
2222
'RestartApache2',
2323
'UpdateDatabase',
2424
'RunDrakePostUpdate',
@@ -1084,14 +1084,14 @@ namespace Deployotron\Actions {
10841084
}
10851085

10861086
/**
1087-
* Create a VERSION.txt file.
1087+
* Create a VERSION.yml file.
10881088
*/
1089-
class CreateVersionTxt extends Action {
1090-
static protected $description = 'Create VERSION.txt.';
1091-
static protected $runMessage = 'Creating VERSION.txt';
1092-
static protected $short = 'create VERSION.txt';
1093-
static protected $killSwitch = 'no-create-version-txt';
1094-
static protected $versionTxt = NULL;
1089+
class CreateVersionYaml extends Action {
1090+
static protected $description = 'Create VERSION.yml.';
1091+
static protected $runMessage = 'Creating VERSION.yml';
1092+
static protected $short = 'create VERSION.yml';
1093+
static protected $killSwitch = 'no-create-version-yml';
1094+
static protected $versionYaml = NULL;
10951095

10961096
/**
10971097
* {@inheritdoc}
@@ -1102,30 +1102,30 @@ namespace Deployotron\Actions {
11021102
$this->shLocal('git tag --points-at ' . $state['deployed_sha']);
11031103
$tags = implode(', ', $this->shOutputArray());
11041104

1105-
$version_txt = array();
1106-
$version_txt[] = 'Deployment info';
1107-
$version_txt[] = '---------------';
1105+
$version_yml = array();
1106+
$version_yml[] = '# Deployment info';
1107+
$version_yml[] = '';
11081108
if (!empty($state['requested_branch'])) {
1109-
$version_txt[] = 'Branch: ' . $state['requested_branch'];
1109+
$version_yml[] = '- Branch: ' . $state['requested_branch'];
11101110
}
11111111
if (!empty($tags)) {
1112-
$version_txt[] = 'Tags: ' . $tags;
1112+
$version_yml[] = '- Tags: ' . $tags;
11131113
}
1114-
$version_txt[] = 'SHA: ' . $state['deployed_sha'];
1115-
$version_txt[] = 'Time of deployment: ' . date('r');
1116-
$version_txt[] = 'Deployer: ' . $_SERVER['USER'] . '@' . php_uname('n');
1114+
$version_yml[] = '- SHA: ' . $state['deployed_sha'];
1115+
$version_yml[] = '- Time of deployment: ' . date('r');
1116+
$version_yml[] = '- Deployer: ' . $_SERVER['USER'] . '@' . php_uname('n');
11171117

1118-
// Delete any pre-existing VERSION.txt file and create a new one.
1119-
$this->sh('rm VERSION.txt');
1118+
// Delete any pre-existing VERSION.yml file and create a new one.
1119+
$this->sh('rm VERSION.yml');
11201120
// You'd think that echo would do the job, but it's not consistent
11211121
// across shells. Bash and most /bin/echo requires the -n option to
11221122
// expand \n to a newline, while /bin/sh built-in echo doesn't and
11231123
// prints the -n as part of the output. But printf works the same and is
11241124
// POSIX 7, which should cover our bases.
1125-
$this->sh('printf ' . escapeshellarg(implode("\\n", $version_txt) . "\\n") . ' > VERSION.txt');
1125+
$this->sh('printf ' . escapeshellarg(implode("\\n", $version_yml) . "\\n") . ' > VERSION.yml');
11261126
}
11271127
else {
1128-
drush_log(dt('No version deployed, not creating/updating VERSION.txt.'), 'warning');
1128+
drush_log(dt('No version deployed, not creating/updating VERSION.yml.'), 'warning');
11291129
}
11301130
return TRUE;
11311131
}

tests/deployotronTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ public function testBasic() {
210210
$this->assertRegExp('/More than one of branch\\/tag\\/sha specified, using sha./', $this->getOutput());
211211
$this->assertRegExp('/HEAD now at 04256b5992d8b4a4fae25c7cb7888583749fabc0/', $this->getOutput());
212212

213-
// Check that VERSION.txt was created.
214-
$this->assertFileExists($this->deploySite() . '/VERSION.txt');
213+
// Check that VERSION.yml was created.
214+
$this->assertFileExists($this->deploySite() . '/VERSION.yml');
215215

216216
// Check that a invalid tag/branch prints the proper error message.
217217
$this->drush('deploy 2>&1', array('@deployotron'), array(
@@ -260,17 +260,17 @@ public function testBasic() {
260260
), NULL, $this->webroot());
261261
$this->assertRegExp('/HEAD now at b9471948c3f83a665dd4f106aba3de8962d69b42/', $this->getOutput());
262262

263-
// VERSION.txt should still exist.
264-
$this->assertFileExists($this->deploySite() . '/VERSION.txt');
263+
// VERSION.yml should still exist.
264+
$this->assertFileExists($this->deploySite() . '/VERSION.yml');
265265
// Check content.
266-
$version_txt = file_get_contents($this->deploySite() . '/VERSION.txt');
267-
$this->assertRegExp('/Deployment info/', $version_txt);
268-
$this->assertRegExp('/SHA: b9471948c3f83a665dd4f106aba3de8962d69b42/', $version_txt);
269-
$this->assertRegExp('/Time of deployment: /', $version_txt);
270-
$this->assertRegExp('/Deployer: /', $version_txt);
266+
$version_yml = file_get_contents($this->deploySite() . '/VERSION.yml');
267+
$this->assertRegExp('/Deployment info/', $version_yml);
268+
$this->assertRegExp('/SHA: b9471948c3f83a665dd4f106aba3de8962d69b42/', $version_yml);
269+
$this->assertRegExp('/Time of deployment: /', $version_yml);
270+
$this->assertRegExp('/Deployer: /', $version_yml);
271271

272272
// Check that the switch for echo didn't got written to the file.
273-
$this->assertNotRegExp('/-e/', $version_txt);
273+
$this->assertNotRegExp('/-e/', $version_yml);
274274

275275
// Check that a file in the way of a new file will cause the deployment to
276276
// roll back.
@@ -290,9 +290,9 @@ public function testBasic() {
290290
unlink($this->deploySite() . '/sites/all/modules/coffee');
291291
$this->drush('deploy 2>&1', array('@deployotron'), array('y' => TRUE), NULL, $this->webroot());
292292
$this->assertRegExp('/HEAD now at fbcaa29d45716edcbedc3c325bfbab828f1ce838/', $this->getOutput());
293-
$version_txt = file_get_contents($this->deploySite() . '/VERSION.txt');
294-
$this->assertRegExp('/Branch: master/', $version_txt);
295-
$this->assertRegExp('/SHA: fbcaa29d45716edcbedc3c325bfbab828f1ce838/', $version_txt);
293+
$version_yml = file_get_contents($this->deploySite() . '/VERSION.yml');
294+
$this->assertRegExp('/Branch: master/', $version_yml);
295+
$this->assertRegExp('/SHA: fbcaa29d45716edcbedc3c325bfbab828f1ce838/', $version_yml);
296296
}
297297

298298
/**
@@ -462,7 +462,7 @@ public function testCommandOverride() {
462462
/**
463463
* Test no-deploy.
464464
*
465-
* And that Flowdock and VERSION.txt prints the appropriate message.
465+
* And that Flowdock and VERSION.yml prints the appropriate message.
466466
*/
467467
public function testNoDeploy() {
468468
$this->writeAlias(array(
@@ -480,8 +480,8 @@ public function testNoDeploy() {
480480
'no-deploy' => TRUE,
481481
'flowdock-token' => $this->flowdockToken,
482482
), NULL, $this->webroot());
483-
// Check VERSION.txt message.
484-
$this->assertRegExp('/No version deployed, not creating\/updating VERSION.txt/', $this->getOutput());
483+
// Check VERSION.yml message.
484+
$this->assertRegExp('/No version deployed, not creating\/updating VERSION.yml/', $this->getOutput());
485485

486486
// Check Flowdock message.
487487
$this->assertRegExp('/No version deployed, not sending Flowdock notification/', $this->getOutput());

0 commit comments

Comments
 (0)