Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed getOpenMageVersion() #4496

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 38 additions & 35 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

use Composer\InstalledVersions;

define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('BP', dirname(__DIR__));
Expand Down Expand Up @@ -178,64 +180,65 @@ public static function getVersionInfo()
* @link https://openmage.github.io/supported-versions.html
* @link https://semver.org/
*/
public static function getOpenMageVersion(): string
public static function getOpenMageVersion(bool $withHas = false): string
{
$info = self::getOpenMageVersionInfo();
$versionString = "{$info['major']}.{$info['minor']}.{$info['patch']}";

if ($info['stability'] && $info['number']) {
return "{$versionString}-{$info['stability']}.{$info['number']}";
}
if ($info['stability']) {
return "{$versionString}-{$info['stability']}";
$versionfromGit = self::getVersionFromGit($withHas);
if ($versionfromGit) {
return $versionfromGit;
}
if ($info['number']) {
return "{$versionString}-{$info['number']}";

$versionfromComposer = self::getVersionFromComposer();
if ($versionfromComposer) {
return $versionfromComposer;
}

return $versionString;
return '';
}

/**
* Gets the detailed OpenMage version information
* @link https://openmage.github.io/supported-versions.html
* @link https://semver.org/
* @deprecated
*/
public static function getOpenMageVersionInfo(): array
{
/**
* This code construct is to make merging for forward porting of changes easier.
* By having the version numbers of different branches in own lines, they do not provoke a merge conflict
* also as releases are usually done together, this could in theory be done at once.
* The major Version then needs to be only changed once per branch.
*/
if (self::getOpenMageMajorVersion() === 20) {
return [
'major' => '20',
'minor' => '12',
'patch' => '0',
'stability' => '', // beta,alpha,rc
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
];
}

return [
'major' => '19',
'minor' => '5',
'patch' => '3',
'stability' => '', // beta,alpha,rc
'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9
];
return explode('.', ltrim(self::getOpenMageVersion(), 'v'));
}

/**
* @return int<19,20>
* @deprecated
*/
public static function getOpenMageMajorVersion(): int
{
return 20;
}

public static function getVersionFromComposer(): ?string
{
if (!InstalledVersions::isInstalled('openmage/magento-lts')) {
return null;
}

return InstalledVersions::getVersion('openmage/magento-lts');
}

public static function getVersionFromGit(bool $withHas = true): ?string
{
if (!function_exists('exec')) {
return null;
}

$commitTag = trim(exec('git describe --tags --abbrev=0'));
if (!$withHas) {
return $commitTag;
}

$commitHash = trim(exec('git log --pretty="%h" -n1 HEAD'));
return sprintf('%s (%s)', $commitTag, $commitHash);
}

/**
* Get current Magento edition
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
<a href="<?php echo $this->getOpenMageProjectUrl() ?>" target="_blank"><?php echo $this->__('OpenMage Project') ?></a> |
<a href="<?php echo $this->getReportIssuesUrl() ?>" target="_blank"><?php echo $this->__('Report Issues') ?></a>
</p>
<?php echo $this->__('OpenMage %s', Mage::getOpenMageVersion()) ?>
<?php if (Mage::getIsDeveloperMode()): ?>
<?php echo $this->__('OpenMage %s', Mage::getOpenMageVersion(true)) ?>
<?php endif ?>
<script type="text/javascript">
function setInterfaceLanguage(evt) {
var elem = Event.element(evt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/** @var Mage_Adminhtml_Block_Page_Header $this */
?>
<div class="header-top">
<a href="<?php echo $this->getHomeLink() ?>" class="logo" title="<?php echo $this->__('OpenMage ver. %s', Mage::getOpenMageVersion()) ?>">
<a href="<?php echo $this->getHomeLink() ?>" class="logo" title="<?php echo $this->__('OpenMage') ?>">
<svg version="1.1" id="magentologo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="40px" viewBox="0 0 20 40" enable-background="new 0 0 20 40" xml:space="preserve">
<path fill="#FFFFFF" d="M12.9,23.4V30H7.5v-6.3c0-1,0.3-1.8,0.8-2.3c0.5-0.5,1.2-0.8,2-0.8c0.8,0,1.5,0.2,1.9,0.7 C12.7,21.8,12.9,22.5,12.9,23.4z M3.8,21.3c-0.5-0.5-1.1-0.7-1.9-0.7c-0.8,0-1.4,0.2-1.9,0.7V30h4.5v-6.6 C4.5,22.5,4.3,21.8,3.8,21.3z M16.2,10H0v9.1c0.2-0.2,0.4-0.4,0.6-0.5C1.3,18.2,2.1,18,3,18c1,0,1.8,0.2,2.5,0.7 c0.7,0.5,1.2,1.1,1.6,2c0.4-0.8,0.9-1.5,1.7-1.9c0.7-0.5,1.6-0.7,2.5-0.7c1.4,0,2.6,0.4,3.4,1.3c0.8,0.9,1.3,2.2,1.3,3.8V30H20V13.8 C20,11.7,18.3,10,16.2,10z"/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="footer-container">
<div class="footer">
<?php echo $this->getChildHtml() ?>
<p class="bugs"><?php echo $this->__('Help Us to Keep OpenMage Healthy') ?> - <a href="https://github.com/OpenMage/magento-lts/issues" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a> <?php echo $this->__('(ver. %s)', Mage::getOpenMageVersion()) ?></p>
<p class="bugs"><?php echo $this->__('Help Us to Keep OpenMage Healthy') ?> - <a href="https://github.com/OpenMage/magento-lts/issues" onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a></p>
<address><?php echo $this->getCopyright() ?></address>
</div>
</div>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"ext-simplexml": "*",
"ext-soap": "*",
"ext-zlib": "*",
"composer-runtime-api": "^2",
"colinmollenhour/cache-backend-redis": "^1.14",
"colinmollenhour/magento-redis-session": "^3.2.0",
"cweagans/composer-patches": "^1.7",
Expand All @@ -47,7 +48,6 @@
},
"require-dev": {
"ext-xmlreader": "*",
"composer/composer": "^2.7",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"friendsofphp/php-cs-fixer": "^3.6",
"macopedia/phpstan-magento1": "^1.1",
Expand Down
Loading
Loading