public function handle() { $projects = []; $choices = []; foreach ($this->factory->getProjects() as $project) { if ($project->config('enable_git_hook', false) === true) { $projects[] = $project; $choices[] = $project->getName(); } } $project = $this->choice('Pick the git enabled project you wish to sync', $choices); if ($this->option('queue')) { app('codex.hooks.git')->createSyncJob($project); $this->comment('Created sync job and pushed it onto the queue.'); } else { $this->comment('Starting synchronisation. This might take a while.'); app('codex.hooks.git')->gitSyncer($this->factory->getProject($project))->syncAll(); } }
protected function applyToGitProjects($remote, \Closure $closure) { foreach ($this->codex->getProjects() as $project) { if ($project->config('enable_git_hook', false) === false || $project->config('git_hook_settings.webhook.enabled', false) === false) { continue; } $config = $project->config('git_hook_settings'); $projectRepo = $project->config('git_hook_settings.owner') . '/' . $project->config('git_hook_settings.repository'); $hook = call_user_func_array($closure, [$project]); if ($hook instanceof Response) { return $hook; } if ($hook['repository'] !== $projectRepo) { continue; } $this->factory->createSyncJob($project); $this->codex->log('info', 'codex.hooks.git.webhook.call', ['remote' => $remote]); return response('', 200); } }