Exemplo n.º 1
0
 /**
  *
  * Behaviour extracted from official email hook prep_for_email() function
  *
  * @param GitRepository $repository
  * @param PFUser $user
  * @param type $oldrev
  * @param type $newrev
  * @param type $refname
  * @return Git_Hook_PushDetails
  */
 public function getPushDetails(GitRepository $repository, PFUser $user, $oldrev, $newrev, $refname)
 {
     $change_type = Git_Hook_PushDetails::ACTION_ERROR;
     $revision_list = array();
     $rev_type = '';
     try {
         if ($oldrev == self::FAKE_EMPTY_COMMIT) {
             $revision_list = $this->exec_repo->revListSinceStart($refname, $newrev);
             $change_type = Git_Hook_PushDetails::ACTION_CREATE;
         } elseif ($newrev == self::FAKE_EMPTY_COMMIT) {
             $change_type = Git_Hook_PushDetails::ACTION_DELETE;
         } else {
             $revision_list = $this->exec_repo->revList($oldrev, $newrev);
             $change_type = Git_Hook_PushDetails::ACTION_UPDATE;
         }
         if ($change_type == Git_Hook_PushDetails::ACTION_DELETE) {
             $rev_type = $this->exec_repo->getObjectType($oldrev);
         } else {
             $rev_type = $this->exec_repo->getObjectType($newrev);
         }
     } catch (Git_Command_Exception $exception) {
         $this->logger->error(__CLASS__ . " {$repository->getFullName()} {$refname} {$oldrev} {$newrev} " . $exception->getMessage());
     }
     return new Git_Hook_PushDetails($repository, $user, $refname, $change_type, $rev_type, $revision_list);
 }