Skip to content

Commit

Permalink
Fix the version used in the PHAR (#259)
Browse files Browse the repository at this point in the history
Closes #257
  • Loading branch information
theofidry committed Aug 10, 2018
1 parent e7eb4b8 commit 6dc68c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,6 +8,7 @@
/fixtures/set004/scoper.inc.php
/fixtures/*/.box_dump/
/fixtures/*/vendor/
.phpunit*
/vendor/
/vendor-bin/*/vendor/
/vendor-bin/*/bin/
Expand Down
1 change: 1 addition & 0 deletions box.json.dist
Expand Up @@ -7,6 +7,7 @@
"files": [
"src/scoper.inc.php.tpl"
],
"git": "git_version_placeholder",

"compression": "GZ",

Expand Down
6 changes: 5 additions & 1 deletion src/functions.php
Expand Up @@ -66,9 +66,13 @@ function create_application(): SymfonyApplication
*/
function get_version(): string
{
if ('phar:' === substr(__FILE__, 0, 5)) {
return '@git_version_placeholder@';
}

$rawVersion = Versions::getVersion('humbug/php-scoper');

list($prettyVersion, $commitHash) = explode('@', $rawVersion);
[$prettyVersion, $commitHash] = explode('@', $rawVersion);

return (1 === preg_match('/9{7}/', $prettyVersion)) ? $commitHash : $prettyVersion;
}
Expand Down

0 comments on commit 6dc68c3

Please sign in to comment.