Skip to content

Commit f547ae9

Browse files
author
Sebastian Feldmann
committed
Merge branch 'master' into 5.1
2 parents a4b8ce0 + ba538e7 commit f547ae9

File tree

7 files changed

+91
-81
lines changed

7 files changed

+91
-81
lines changed

build.xml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,6 @@
8484
</antcall>
8585
</target>
8686

87-
<target name="phar-alpha"
88-
description="Create PHAR archive of PHPUnit and all its dependencies (alpha)"
89-
depends="phar-prepare">
90-
<antcall target="phar-build">
91-
<param name="version" value="alpha"/>
92-
</antcall>
93-
</target>
94-
95-
<target name="phar-beta"
96-
description="Create PHAR archive of PHPUnit and all its dependencies (beta)"
97-
depends="phar-prepare">
98-
<antcall target="phar-build">
99-
<param name="version" value="beta"/>
100-
</antcall>
101-
</target>
102-
10387
<target name="phar-prepare" depends="clean">
10488
<mkdir dir="${basedir}/build/phar"/>
10589

@@ -393,15 +377,6 @@
393377
</fileset>
394378
</copy>
395379

396-
<copy file="${basedir}/vendor/sebastian/version/LICENSE"
397-
tofile="${basedir}/build/phar/lib/sebastian-version/LICENSE"/>
398-
<copy todir="${basedir}/build/phar/lib/sebastian-version">
399-
<fileset dir="${basedir}/vendor/sebastian/version/src">
400-
<include name="**/*.php"/>
401-
<exclude name="**/autoload.php"/>
402-
</fileset>
403-
</copy>
404-
405380
<!-- SOFTLAYER -->
406381
<copy file="${basedir}/vendor/softlayer/objectstorage/COPYING"
407382
tofile="${basedir}/build/phar/lib/softlayer-os/LICENSE"/>
@@ -450,8 +425,6 @@
450425
</fileset>
451426
</copy>
452427

453-
<exec executable="${basedir}/build/phar-patch.php"/>
454-
455428
</target>
456429

457430

@@ -470,7 +443,6 @@
470443
<arg value="--all"/>
471444
<arg value="--phar"/>
472445
<arg value="--gzip"/>
473-
<!-- <arg value="- -bzip2" /> -->
474446
<arg value="--output"/>
475447
<arg path="${basedir}/build/phpbu-${phar_version}.phar"/>
476448
<arg value="--template"/>

build/phar-patch.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

build/phar-version.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,28 @@
44
exit(1);
55
}
66

7-
$arg = trim($argv[1]);
7+
require __DIR__ . '/../vendor/autoload.php';
88

9-
if ($arg == 'alpha' || $arg == 'beta') {
10-
$version = sprintf('%s-%s', $argv[1], date('Y-m-d'));
11-
} else {
12-
$version = $arg;
13-
}
9+
$version = trim($argv[1]);
10+
11+
if (strpos($version, 'dev') !== false) {
12+
// smuggle in a more informative dev version number
13+
try {
14+
$repository = new SebastianFeldmann\Git\Repository(dirname(__DIR__));
15+
$info = $repository->getInfoOperator();
16+
$version = $info->getCurrentTag();
1417

15-
file_put_contents(
16-
__DIR__ . '/phar/Version.php',
17-
str_replace(
18-
'private static $pharVersion;',
19-
'private static $pharVersion = "' . $version . '";',
20-
file_get_contents(__DIR__ . '/phar/Version.php')
21-
)
22-
);
18+
file_put_contents(
19+
__DIR__ . '/phar/Version.php',
20+
preg_replace(
21+
'#new self\\(\'.*\',#',
22+
'new self(\'' . $version . '\',',
23+
file_get_contents(__DIR__ . '/phar/Version.php')
24+
)
25+
);
26+
} catch (\Exception $e) {
27+
exit(1);
28+
}
29+
}
2330

2431
echo $version;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
"ext-json": "*",
3737
"ext-spl": "*",
3838
"sebastian/environment": "~1.1|~2.0|~3.0",
39-
"sebastian/version": "~1.0|~2.0",
4039
"sebastianfeldmann/cli": "~2.0",
4140
"sebastianfeldmann/ftp": "~0.9",
4241
"swiftmailer/swiftmailer": "~5.3|~6.0",
4342
"symfony/event-dispatcher": "~2.6|~3.0|~4.0"
4443
},
4544
"require-dev": {
45+
"sebastianfeldmann/git": "~1.0",
4646
"aws/aws-sdk-php": "~3.10",
4747
"kunalvarma05/dropbox-php-sdk": "~0.2",
4848
"phpseclib/phpseclib": "~2.0",

src/Backup/Collector/Local.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ class Local extends Abstraction implements Collector
2828
*/
2929
public function __construct(Target $target)
3030
{
31-
$this->target = $target;
32-
$this->fileRegex = Util\Path::datePlaceholdersToRegex($this->target->getFilenameRaw());
31+
$this->target = $target;
3332
}
3433

3534
/**
3635
* Collect all created backups.
3736
*/
3837
protected function collectBackups()
3938
{
39+
$this->fileRegex = Util\Path::datePlaceholdersToRegex($this->target->getFilenameRaw());
4040
$this->collect($this->target->getPath()->getPathThatIsNotChanging());
4141
}
4242

src/Version.php

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,70 @@
1717
class Version
1818
{
1919
/**
20-
* Version of the phar file.
21-
* Is getting set via the phar build process.
20+
* Current version
2221
*
2322
* @var string
2423
*/
25-
private static $pharVersion;
24+
private static $version;
2625

2726
/**
28-
* Current version
27+
* Path to application root directory.
2928
*
3029
* @var string
3130
*/
32-
private static $version;
31+
private $path;
3332

3433
/**
35-
* Return the current version of PHPUnit.
34+
* Current release version.
35+
*
36+
* @var string
37+
*/
38+
private $release;
39+
40+
/**
41+
* Current version number.
42+
*
43+
* @var string
44+
*/
45+
private $number;
46+
47+
/**
48+
* @param string $release
49+
* @param string $path
50+
*/
51+
public function __construct($release, $path)
52+
{
53+
$this->release = $release;
54+
$this->path = $path;
55+
}
56+
57+
/**
58+
* Return the full version number.
3659
*
3760
* @return string
3861
*/
39-
public static function id() : string
62+
public function getVersionNumber()
4063
{
41-
if (self::$pharVersion !== null) {
42-
return self::$pharVersion;
64+
if ($this->number === null) {
65+
if (count(explode('.', $this->release)) == 3) {
66+
$this->number = $this->release;
67+
} else {
68+
$this->number = $this->release . '-dev';
69+
}
4370
}
71+
return $this->number;
72+
}
4473

74+
/**
75+
* Return the current version of PHPUnit.
76+
*
77+
* @return string
78+
*/
79+
public static function id() : string
80+
{
4581
if (self::$version === null) {
46-
$version = new SebastianBergmann\Version('5.1.2', dirname(dirname(__DIR__)));
47-
self::$version = $version->getVersion();
82+
$version = new self('5.1.3', dirname(dirname(__DIR__)));
83+
self::$version = $version->getVersionNumber();
4884
}
4985

5086
return self::$version;

tests/phpbu/VersionTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,24 @@ public function testGetVersion()
3535

3636
$this->assertEquals('phpbu 5.1', substr($version, 0, 9), 'version should match');
3737
}
38+
39+
/**
40+
* Tests Version::getVersionNumber
41+
*/
42+
public function testVersionNumberDev()
43+
{
44+
$version = new Version('5.1', dirname(dirname(dirname(__DIR__))));
45+
46+
$this->assertEquals('5.1-dev', $number = $version->getVersionNumber());
47+
}
48+
49+
/**
50+
* Tests Version::getVersionNumber
51+
*/
52+
public function testVersionNumberRelease()
53+
{
54+
$version = new Version('5.1.0', dirname(dirname(dirname(__DIR__))));
55+
56+
$this->assertEquals('5.1.0', $number = $version->getVersionNumber());
57+
}
3858
}

0 commit comments

Comments
 (0)