コード例 #1
0
ファイル: RevListCommand.php プロジェクト: ocubom/GitElephant
 /**
  * get the commits path to the passed commit. Useful to count commits in a repo
  *
  * @param \GitElephant\Objects\Commit $commit commit instance
  * @param int                         $max    max count
  *
  * @throws \RuntimeException
  * @return string
  */
 public function commitPath(Commit $commit, $max = 1000)
 {
     $this->clearAll();
     $this->addCommandName(static::GIT_REVLIST);
     $this->addCommandArgument(sprintf('--max-count=%s', $max));
     $this->addCommandSubject($commit->getSha());
     return $this->getCommand();
 }
コード例 #2
0
ファイル: Revision.php プロジェクト: mlukman/gitsync
 /**
  * Get the revision SHA digest
  * @param boolean $short True to get only first 8 characters, false to return all 40 characters
  * @return string
  */
 public function getSHA($short = false)
 {
     return $this->commit->getSha($short);
 }
コード例 #3
0
ファイル: Context.php プロジェクト: mlukman/gitsync
 protected function auditEvent(Commit $new_head, Commit $old_head = null, $by = null)
 {
     if (($fn = $this->getAuditFile()) && ($file = \fopen($fn, 'a'))) {
         // event name
         $event = '';
         if (!$old_head) {
             $event = 'INIT';
         } elseif ($new_head->getSha() == $old_head->getSha()) {
             $event = 'RESET';
         } elseif ($new_head->getDatetimeAuthor() > $old_head->getDatetimeAuthor()) {
             $event = 'UPDATE';
         } else {
             $event = 'ROLLBACK';
         }
         if ($new_head->getSha() == $this->getRepo()->getCommit($this->branch_name)) {
             $event .= ' TO LATEST';
         }
         $audit = new Audit($by ?: '-', $event, $old_head ? sprintf('%s @ %s - %s', $old_head->getSha(true), $old_head->getDatetimeAuthor()->format('Ymd_Hi'), $old_head->getMessage()) : null, sprintf('%s @ %s - %s', $new_head->getSha(true), $new_head->getDatetimeAuthor()->format('Ymd_Hi'), $new_head->getMessage()));
         \fwrite($file, $audit->serialize() . "\n");
         \fclose($file);
     }
 }