Пример #1
0
 /**
  * Prints revisions.
  *
  * @param RevisionLog     $revision_log Revision log.
  * @param array           $revisions    Revisions.
  * @param OutputInterface $output       Output.
  *
  * @return void
  */
 public function printRevisions(RevisionLog $revision_log, array $revisions, OutputInterface $output)
 {
     $table = new Table($output);
     $headers = array('Revision', 'Author', 'Date', 'Bug-ID', 'Log Message');
     $with_full_message = in_array(self::COLUMN_FULL_MESSAGE, $this->_columns);
     $with_details = in_array(self::COLUMN_DETAILS, $this->_columns);
     // Add "Summary" header.
     $with_summary = in_array(self::COLUMN_SUMMARY, $this->_columns);
     if ($with_summary) {
         $headers[] = 'Summary';
     }
     // Add "Refs" header.
     $with_refs = in_array(self::COLUMN_REFS, $this->_columns);
     if ($with_refs) {
         $headers[] = 'Refs';
     }
     $with_merge_oracle = in_array(self::COLUMN_MERGE_ORACLE, $this->_columns);
     // Add "M.O." header.
     if ($with_merge_oracle) {
         $headers[] = 'M.O.';
     }
     // Add "Merged Via" header.
     $with_merge_status = in_array(self::COLUMN_MERGE_STATUS, $this->_columns);
     if ($with_merge_status) {
         $headers[] = 'Merged Via';
     }
     $table->setHeaders($headers);
     $prev_bugs = null;
     $last_color = 'yellow';
     $last_revision = end($revisions);
     $project_path = $revision_log->getProjectPath();
     $bugs_per_row = $with_details ? 1 : 3;
     $revisions_data = $revision_log->getRevisionsData('summary', $revisions);
     $revisions_paths = $revision_log->getRevisionsData('paths', $revisions);
     $revisions_bugs = $revision_log->getRevisionsData('bugs', $revisions);
     $revisions_refs = $revision_log->getRevisionsData('refs', $revisions);
     if ($with_merge_status) {
         $revisions_merged_via = $revision_log->getRevisionsData('merges', $revisions);
         $revisions_merged_via_refs = $revision_log->getRevisionsData('refs', call_user_func_array('array_merge', $revisions_merged_via));
     }
     foreach ($revisions as $revision) {
         $revision_data = $revisions_data[$revision];
         $new_bugs = $revisions_bugs[$revision];
         if (isset($prev_bugs) && $new_bugs !== $prev_bugs) {
             $last_color = $last_color === 'yellow' ? 'magenta' : 'yellow';
         }
         $row = array($revision, $revision_data['author'], $this->_dateHelper->getAgoTime($revision_data['date']), $this->_outputHelper->formatArray($new_bugs, $bugs_per_row, $last_color), $this->_generateLogMessageColumn($with_full_message || $with_details, $revision_data));
         $revision_paths = $revisions_paths[$revision];
         // Add "Summary" column.
         if ($with_summary) {
             $row[] = $this->_generateSummaryColumn($revision_paths);
         }
         // Add "Refs" column.
         if ($with_refs) {
             $row[] = $this->_outputHelper->formatArray($revisions_refs[$revision], 1);
         }
         // Add "M.O." column.
         if ($with_merge_oracle) {
             $merge_conflict_prediction = $this->_getMergeConflictPrediction($revision_paths);
             $row[] = $merge_conflict_prediction ? '<error>' . count($merge_conflict_prediction) . '</error>' : '';
         } else {
             $merge_conflict_prediction = array();
         }
         // Add "Merged Via" column.
         if ($with_merge_status) {
             $row[] = $this->_generateMergedViaColumn($revisions_merged_via[$revision], $revisions_merged_via_refs);
         }
         if ($revision === $this->_currentRevision) {
             foreach ($row as $index => $cell) {
                 $row[$index] = $this->applyStyle($cell, 'fg=white;options=bold');
             }
         }
         $table->addRow($row);
         if ($with_details) {
             $details = $this->_generateDetailsRowContent($revision, $revisions_refs, $revision_paths, $merge_conflict_prediction, $project_path);
             $table->addRow(new TableSeparator());
             $table->addRow(array(new TableCell($details, array('colspan' => count($headers)))));
             if ($revision != $last_revision) {
                 $table->addRow(new TableSeparator());
             }
         }
         $prev_bugs = $new_bugs;
     }
     $table->render();
     $this->_resetState();
 }
Пример #2
0
 public function testGetName()
 {
     $this->assertEquals('date', $this->dateHelper->getName());
 }