Read commit ID by executing Git at status page

This commit is contained in:
Pig Fang 2019-11-26 17:31:37 +08:00
parent c665adf1c8
commit ff6277a0ca
3 changed files with 292 additions and 215 deletions

View File

@ -17,6 +17,7 @@ use App\Services\OptionForm;
use Illuminate\Http\Request;
use App\Services\PluginManager;
use Illuminate\Support\Collection;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Redis;
class AdminController extends Controller
@ -380,20 +381,35 @@ class AdminController extends Controller
->with('forms', compact('resources', 'redis', 'cache'));
}
public function status(Request $request, PluginManager $plugins)
{
public function status(
Request $request,
PluginManager $plugins,
Filesystem $filesystem
) {
$db = get_db_config();
$enabledPlugins = $plugins->getEnabledPlugins()->map(function ($plugin) {
return ['title' => trans($plugin->title), 'version' => $plugin->version];
});
if ($filesystem->exists(base_path('.git'))) {
$process = new \Symfony\Component\Process\Process(
['git', 'log', '--pretty=%H', '-1']
);
$process->run();
$commit = $process->isSuccessful() ? trim($process->getOutput()) : '';
}
return view('admin.status')
->with('detail', [
'bs' => [
'version' => config('app.version'),
'env' => config('app.env'),
'debug' => config('app.debug') ? trans('general.yes') : trans('general.no'),
'commit' => Str::limit(resolve(\App\Services\Webpack::class)->commit, 10, ''),
'commit' => Str::limit(
$commit ?? resolve(\App\Services\Webpack::class)->commit,
16,
''
),
'laravel' => app()->version(),
],
'server' => [

View File

@ -26,6 +26,7 @@
"composer/ca-bundle": "^1.2",
"facade/ignition": "^1.4",
"spatie/laravel-translation-loader": "^2.4",
"symfony/process": "^4.4",
"symfony/yaml": "^4.3",
"twig/twig": "^2.11",
"rcrowe/twigbridge": "^0.11.1"

484
composer.lock generated

File diff suppressed because it is too large Load Diff