Exemplo n.º 1
0
function addCommitToGroup(&$groups, $groupName, &$commit)
{
    if (!is_array($groups)) {
        throw new Exception('Invalid groups argument, array expected');
    }
    $key = array_casekey_exists($groupName, $groups);
    if ($key === false) {
        $groups[$groupName] = array();
        $group =& $groups[$groupName];
    } else {
        $group =& $groups[$key];
    }
    $group[] = $commit;
}
 /**
  * Produce a indexable directory of BuildEvents from the Packages
  * collection, grouping them according to the version number of the
  * 'Doomsday' packages those events produced.
  *
  * The version number (string) is used as key to each record.
  *
  * @param matrix  (Array) will be populated with new records.
  * @return  (Mixed) FALSE if no packages were added to the matrix
  *          otherwise the number of added packages (integer).
  */
 private function populateReleases(&$releases)
 {
     if (!is_array($releases)) {
         throw new Exception('populateReleases: Invalid matrix argument, array expected.');
     }
     if (!isset($this->packages)) {
         return FALSE;
     }
     // Running total of the number of events we add to the matrix.
     $numEventsAdded = (int) 0;
     foreach ($this->packages as &$pack) {
         // We are only interested in the 'Doomsday' packages.
         if ($pack->title() !== 'Doomsday') {
             continue;
         }
         // Have we encountered this version before?.
         $versionText = "{$pack->version()}";
         $key = array_casekey_exists($versionText, $releases);
         if ($key === false) {
             // Not yet construct a new record and associate it
             // in the release list using the version number as the key.
             $key = ucwords($versionText);
             $releases[$key] = $this->newReleaseInfo($key);
             $releaseInfo =& $releases[$key];
         } else {
             $releaseInfo =& $releases[$versionText];
         }
         $build = NULL;
         // Is this package a product of the autobuilder?
         if ($pack instanceof iBuilderProduct) {
             // Yes; we have "real" BuildEvent we can link with this.
             $buildUniqueId = $pack->buildUniqueId();
             $build = $this->buildByUniqueId($buildUniqueId);
         } else {
             // No - this must be a symbolic package.
             // We'll instantiate a symbolic BuildEvent for this.
             $build = new BuildEvent(0, $pack->hasReleaseDate() ? $pack->releaseDate() : strtotime('Jan 8, 2005'), 'skyjake', '*****@*****.**', RT_STABLE);
             if ($pack->hasReleaseNotesUri()) {
                 $build->setReleaseNotesUri($pack->releaseNotesUri());
             }
             if ($pack->hasReleaseChangeLogUri()) {
                 $build->setReleaseChangeLogUri($pack->releaseChangeLogUri());
             }
             $build->addPackage($pack);
         }
         if (!$build instanceof BuildEvent) {
             continue;
         }
         // Odd...
         // Is a build event already present for this release version?
         $latestBuild = isset($releaseInfo['latestBuild']) ? $releaseInfo['latestBuild'] : NULL;
         if ($latestBuild instanceof BuildEvent) {
             // Is this a newer build?
             if ($build->uniqueId() > $latestBuild->uniqueId()) {
                 $releaseInfo['latestBuild'] = $build;
             }
         } else {
             $releaseInfo['latestBuild'] = $build;
         }
         // Promote the status of the release due to this package?
         $releaseTypeId = $build->releaseTypeId();
         if ($releaseTypeId > $releaseInfo['releaseTypeId']) {
             $releaseInfo['releaseTypeId'] = $releaseTypeId;
         }
     }
     return $numEventsAdded;
 }