Skip to content

Commit

Permalink
new Application version strategy - see GH-267
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Jul 9, 2020
1 parent 5b58fb5 commit 70e7589
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.

## [Unreleased]

### Changed

- [Application version strategy](https://github.com/llaville/php-compat-info/issues/267) : `composer/package-versions-deprecated` is used to handle version in Composer/Git strategy

### Removed

- Removes usage of `jean85/pretty-package-versions` package to handle Composer/Git version strategy

## [5.3.0] - 2020-07-08

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ext-pdo_sqlite": "*",
"bartlett/php-reflect": "^4.4",
"bartlett/php-compatinfo-db": "^2.0",
"jean85/pretty-package-versions": "^1.5",
"composer/package-versions-deprecated": "^1.8",
"psr/log": "^1.0"
},
"require-dev": {
Expand Down
24 changes: 16 additions & 8 deletions src/Bartlett/CompatInfo/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Bartlett\CompatInfo\Util\Database;
use Bartlett\Reflect\Console\Application as BaseApplication;

use Jean85\PrettyVersions;
use PackageVersions\Versions;

use OutOfBoundsException;
use function substr_count;

/**
* Console Application.
Expand All @@ -32,7 +32,7 @@
class Application extends BaseApplication
{
public const NAME = 'phpCompatInfo';
public const VERSION = '5.3.x-dev';
public const VERSION = '5.4.x-dev';

/**
* @link http://patorjk.com/software/taag/#p=display&f=Standard&t=phpCompatInfo
Expand All @@ -45,13 +45,21 @@ class Application extends BaseApplication
|_| |_| |_|
";

public function __construct()
public function __construct(string $version = 'UNKNOWN')
{
try {
$version = PrettyVersions::getVersion('bartlett/php-compatinfo')->getPrettyVersion();
} catch (OutOfBoundsException $e) {
if ('UNKNOWN' === $version) {
// composer or git outside world strategy
$version = self::VERSION;
} elseif (substr_count($version, '.') === 2) {
// release is in X.Y.Z format
} else {
// composer or git strategy
$version = Versions::getVersion('bartlett/php-compatinfo');
list($ver, ) = explode('@', $version);

if (strpos($ver, 'dev') === false) {
$version = $ver;
}
}
parent::__construct(self::NAME, $version);
}
Expand Down

0 comments on commit 70e7589

Please sign in to comment.