Example #1
0
 public function getBranchesActivity(Project $project, $branch = null)
 {
     $repository = $project->getRepository();
     $references = $repository->getReferences();
     $branchName = null === $branch ? $project->getDefaultBranch() : $branch;
     $against = $references->getBranch($branchName);
     foreach ($references->getBranches() as $branch) {
         $logBehind = $repository->getLog($repository->getRevision($branch->getFullname() . '..' . $against->getFullname()));
         $logAbove = $repository->getLog($repository->getRevision($against->getFullname() . '..' . $branch->getFullname()));
         $rows[] = array('branch' => $branch, 'above' => $logAbove->count(), 'behind' => $logBehind->count(), 'lastModification' => $branch->getLastModification());
     }
     usort($rows, function ($left, $right) {
         return $left['lastModification']->getAuthorDate() < $right['lastModification']->getAuthorDate();
     });
     return $rows;
 }