#add git monitor

This commit is contained in:
2025-12-18 10:18:25 +08:00
parent 2ec44b5665
commit 5f6bba1d9f
18 changed files with 889 additions and 20 deletions

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use App\Services\GitMonitorService;
use Illuminate\Console\Command;
class GitMonitorCheckCommand extends Command
{
protected $signature = 'git-monitor:check
{--force-cache : 强制从 JIRA 刷新 release 缓存后再检查}';
protected $description = '巡检 release 分支是否包含 develop merge 或因为冲突导致的函数缺失';
public function handle(GitMonitorService $monitor): void
{
if ($this->option('force-cache')) {
$monitor->refreshReleaseCache(true);
} else {
$monitor->ensureReleaseCache();
}
$results = $monitor->checkRepositories(false);
foreach ($results as $repo => $result) {
if (isset($result['error'])) {
$this->error(sprintf('[%s] %s', $repo, $result['error']));
continue;
}
$this->line(sprintf(
'[%s] 分支 %s 已对齐 %s扫描 %d 个提交。',
$repo,
$result['branch'],
$result['head'],
$result['commits_scanned']
));
if (!empty($result['issues']['develop_merges'])) {
$this->warn(sprintf(' - 检测到 %d 个 develop merge', count($result['issues']['develop_merges'])));
}
if (!empty($result['issues']['missing_functions'])) {
$this->warn(sprintf(' - 检测到 %d 个疑似缺失函数的提交', count($result['issues']['missing_functions'])));
}
}
}
}