/** * Execute the job. */ public function handle() { $mirror_dir = $this->project->mirrorPath(); $this->project->refs()->delete(); foreach (['tag', 'branch'] as $ref) { $process = new Process('tools.ListGitReferences', ['mirror_path' => $mirror_dir, 'git_reference' => $ref]); $process->run(); if ($process->isSuccessful()) { foreach (explode(PHP_EOL, trim($process->getOutput())) as $reference) { $reference = trim($reference); if (empty($reference)) { continue; } if (substr($reference, 0, 1) === '*') { $reference = trim(substr($reference, 1)); } Ref::create(['name' => $reference, 'project_id' => $this->project->id, 'is_tag' => $ref === 'tag']); } } } }