Пример #1
0
 public function getBranchesToSync()
 {
     $allowedBranches = $this->setting('sync.constraints.branches');
     if (count($allowedBranches) === 0) {
         return [];
     }
     $this->fire('git.syncer.branches.start', [$allowedBranches]);
     $branchesToSync = [];
     $remote = $this->client($this->setting('remote'));
     $repo = $this->setting('repository');
     $owner = $this->setting('owner');
     $branches = $remote->getBranches($repo, $owner);
     foreach ($branches as $branch => $sha) {
         if (!in_array('*', $allowedBranches, true) and !in_array($branch, $allowedBranches, true)) {
             continue;
         }
         $cacheKey = md5($this->project->getName() . $branch);
         $cached = $this->cache->get($cacheKey, false);
         $destinationPath = Path::join($this->project->getPath(), $branch);
         if ($cached !== $sha || $cached === false || !$this->files->exists($destinationPath)) {
             $branchesToSync[] = $branch;
         }
     }
     $this->fire('git.syncer.branches.finish', [$branchesToSync]);
     return $branchesToSync;
 }
 /**
  * handle
  *
  * @param \Codex\Core\Project $project
  */
 public function handle(Project $project, Menu $menu)
 {
     if (!$project->hasEnabledHook('sassdoc')) {
         return;
     }
     $node = $menu->add('sassdoc', $project->config('hooks.sassdoc.menu_name'));
     $node->setMeta('icon', $project->config('hooks.sassdoc.menu_icon'));
     $node->setAttribute('href', route('codex.hooks.sassdoc', ['projectName' => $project->getName(), 'ref' => $project->getRef()]));
 }