/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/widgets/Version.php
45 строк
1013 B
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\widgets; use common\helpers\DateHelper; use Yii; use yii\bootstrap\Html; /** * Class Version * @package common\widgets */ class Version extends \yii\bootstrap\Widget { /** * display current short commit hash * * @return string * @throws \yii\base\InvalidConfigException */ public function run() { $cmd = 'git log -1 --pretty=format:"%H-%h-%cd"'; $data = explode('-', exec($cmd)); if (count($data) == 3) { $url = Yii::t('app', Yii::$app->params['git']['url'], [ 'commit' => $data[0], ]); $a = Html::a($data[1], $url, [ 'target' => '_blank', 'title' => 'Go to git repository' ]); return Yii::t('app', '{a} at {dt}', [ 'a' => $a, 'dt' => DateHelper::userdate($data[2], true) ]); } else { return exec('git rev-parse --short HEAD'); } } }