mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-14 12:11:32 +00:00
Import latest app updates from streamline
An updated set of source files and initialization was provided by streamline to address issues observed during initial testing. These files have been updated in order to generate a new set of app images.
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/version.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace SebastianBergmann;
|
||||
|
||||
use function end;
|
||||
use function explode;
|
||||
use function fclose;
|
||||
use function is_dir;
|
||||
use function is_resource;
|
||||
use function proc_close;
|
||||
use function proc_open;
|
||||
use function stream_get_contents;
|
||||
use function substr_count;
|
||||
use function trim;
|
||||
|
||||
final class Version
|
||||
{
|
||||
private readonly string $version;
|
||||
|
||||
public function __construct(string $release, string $path)
|
||||
{
|
||||
$this->version = $this->generate($release, $path);
|
||||
}
|
||||
|
||||
public function asString(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
private function generate(string $release, string $path): string
|
||||
{
|
||||
if (substr_count($release, '.') + 1 === 3) {
|
||||
$version = $release;
|
||||
} else {
|
||||
$version = $release . '-dev';
|
||||
}
|
||||
|
||||
$git = $this->getGitInformation($path);
|
||||
|
||||
if (!$git) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
if (substr_count($release, '.') + 1 === 3) {
|
||||
return $git;
|
||||
}
|
||||
|
||||
$git = explode('-', $git);
|
||||
|
||||
return $release . '-' . end($git);
|
||||
}
|
||||
|
||||
private function getGitInformation(string $path): bool|string
|
||||
{
|
||||
if (!is_dir($path . DIRECTORY_SEPARATOR . '.git')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$process = proc_open(
|
||||
'git describe --tags',
|
||||
[
|
||||
1 => ['pipe', 'w'],
|
||||
2 => ['pipe', 'w'],
|
||||
],
|
||||
$pipes,
|
||||
$path
|
||||
);
|
||||
|
||||
if (!is_resource($process)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = trim(stream_get_contents($pipes[1]));
|
||||
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
|
||||
$returnCode = proc_close($process);
|
||||
|
||||
if ($returnCode !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user