#add git monitor
This commit is contained in:
48
app/Console/Commands/GitMonitorCheckCommand.php
Normal file
48
app/Console/Commands/GitMonitorCheckCommand.php
Normal 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'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user