public function getHeraldFieldValue($object)
 {
     $packages = $this->getAdapter()->loadAffectedPackages();
     if (!$packages) {
         return array();
     }
     $owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
     return mpull($owners, 'getUserPHID');
 }
 public function getHeraldField($field)
 {
     $data = $this->commitData;
     switch ($field) {
         case HeraldFieldConfig::FIELD_BODY:
             return $data->getCommitMessage();
         case HeraldFieldConfig::FIELD_AUTHOR:
             return $data->getCommitDetail('authorPHID');
         case HeraldFieldConfig::FIELD_REVIEWER:
             return $data->getCommitDetail('reviewerPHID');
         case HeraldFieldConfig::FIELD_DIFF_FILE:
             return $this->loadAffectedPaths();
         case HeraldFieldConfig::FIELD_REPOSITORY:
             return $this->repository->getPHID();
         case HeraldFieldConfig::FIELD_DIFF_CONTENT:
             // TODO!
             return null;
             /*
                     try {
                       $diff = $this->loadDiff();
                     } catch (Exception $ex) {
                       // See rE280053 for an example.
                       return array(
                         '<<< Failed to load diff, this usually means the change committed '.
                         'a binary file as text. >>>',
                       );
                     }
                     $dict = array();
                     $changes = $diff->getChangesets();
                     $lines = array();
                     foreach ($changes as $change) {
                       $lines = array();
                       foreach ($change->getHunks() as $hunk) {
                         $lines[] = $hunk->makeChanges();
                       }
                       $dict[$change->getTrueFilename()] = implode("\n", $lines);
                     }
                     return $dict;
             */
         /*
                 try {
                   $diff = $this->loadDiff();
                 } catch (Exception $ex) {
                   // See rE280053 for an example.
                   return array(
                     '<<< Failed to load diff, this usually means the change committed '.
                     'a binary file as text. >>>',
                   );
                 }
                 $dict = array();
                 $changes = $diff->getChangesets();
                 $lines = array();
                 foreach ($changes as $change) {
                   $lines = array();
                   foreach ($change->getHunks() as $hunk) {
                     $lines[] = $hunk->makeChanges();
                   }
                   $dict[$change->getTrueFilename()] = implode("\n", $lines);
                 }
                 return $dict;
         */
         case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE:
             $packages = $this->loadAffectedPackages();
             return mpull($packages, 'getPHID');
         case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE_OWNER:
             $packages = $this->loadAffectedPackages();
             $owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
             return mpull($owners, 'getUserPHID');
         case HeraldFieldConfig::FIELD_NEED_AUDIT_FOR_PACKAGE:
             return $this->loadAuditNeededPackage();
         case HeraldFieldConfig::FIELD_DIFFERENTIAL_REVISION:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return null;
             }
             return $revision->getID();
         case HeraldFieldConfig::FIELD_DIFFERENTIAL_REVIEWERS:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return null;
             }
             return $revision->getReviewers();
         case HeraldFieldConfig::FIELD_DIFFERENTIAL_CCS:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return null;
             }
             return $revision->getCCPHIDs();
         default:
             throw new Exception("Invalid field '{$field}'.");
     }
 }
 public function getHeraldField($field)
 {
     $data = $this->commitData;
     switch ($field) {
         case self::FIELD_BODY:
             return $data->getCommitMessage();
         case self::FIELD_AUTHOR:
             return $data->getCommitDetail('authorPHID');
         case self::FIELD_COMMITTER:
             return $data->getCommitDetail('committerPHID');
         case self::FIELD_REVIEWER:
             return $data->getCommitDetail('reviewerPHID');
         case self::FIELD_DIFF_FILE:
             return $this->loadAffectedPaths();
         case self::FIELD_REPOSITORY:
             return $this->repository->getPHID();
         case self::FIELD_REPOSITORY_PROJECTS:
             return $this->repository->getProjectPHIDs();
         case self::FIELD_DIFF_CONTENT:
             return $this->getDiffContent('*');
         case self::FIELD_DIFF_ADDED_CONTENT:
             return $this->getDiffContent('+');
         case self::FIELD_DIFF_REMOVED_CONTENT:
             return $this->getDiffContent('-');
         case self::FIELD_DIFF_ENORMOUS:
             $this->getDiffContent('*');
             return $this->commitDiff instanceof Exception;
         case self::FIELD_AFFECTED_PACKAGE:
             $packages = $this->loadAffectedPackages();
             return mpull($packages, 'getPHID');
         case self::FIELD_AFFECTED_PACKAGE_OWNER:
             $packages = $this->loadAffectedPackages();
             $owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
             return mpull($owners, 'getUserPHID');
         case self::FIELD_NEED_AUDIT_FOR_PACKAGE:
             return $this->loadAuditNeededPackage();
         case self::FIELD_DIFFERENTIAL_REVISION:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return null;
             }
             return $revision->getID();
         case self::FIELD_DIFFERENTIAL_ACCEPTED:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return null;
             }
             $status = $data->getCommitDetail('precommitRevisionStatus', $revision->getStatus());
             switch ($status) {
                 case ArcanistDifferentialRevisionStatus::ACCEPTED:
                 case ArcanistDifferentialRevisionStatus::CLOSED:
                     return $revision->getPHID();
             }
             return null;
         case self::FIELD_DIFFERENTIAL_REVIEWERS:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return array();
             }
             return $revision->getReviewers();
         case self::FIELD_DIFFERENTIAL_CCS:
             $revision = $this->loadDifferentialRevision();
             if (!$revision) {
                 return array();
             }
             return $revision->getCCPHIDs();
         case self::FIELD_BRANCHES:
             $params = array('callsign' => $this->repository->getCallsign(), 'contains' => $this->commit->getCommitIdentifier());
             $result = id(new ConduitCall('diffusion.branchquery', $params))->setUser(PhabricatorUser::getOmnipotentUser())->execute();
             $refs = DiffusionRepositoryRef::loadAllFromDictionaries($result);
             return mpull($refs, 'getShortName');
         case self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH:
             return $this->repository->shouldAutocloseCommit($this->commit);
     }
     return parent::getHeraldField($field);
 }
 public function getHeraldField($field)
 {
     switch ($field) {
         case HeraldFieldConfig::FIELD_TITLE:
             return $this->revision->getTitle();
             break;
         case HeraldFieldConfig::FIELD_BODY:
             return $this->revision->getSummary() . "\n" . $this->revision->getTestPlan();
             break;
         case HeraldFieldConfig::FIELD_AUTHOR:
             return $this->revision->getAuthorPHID();
             break;
         case HeraldFieldConfig::FIELD_DIFF_FILE:
             return $this->loadAffectedPaths();
         case HeraldFieldConfig::FIELD_CC:
             if (isset($this->explicitCCs)) {
                 return array_keys($this->explicitCCs);
             } else {
                 return $this->revision->getCCPHIDs();
             }
         case HeraldFieldConfig::FIELD_REVIEWERS:
             if (isset($this->explicitReviewers)) {
                 return array_keys($this->explicitReviewers);
             } else {
                 return $this->revision->getReviewers();
             }
         case HeraldFieldConfig::FIELD_REPOSITORY:
             $repository = $this->loadRepository();
             if (!$repository) {
                 return null;
             }
             return $repository->getPHID();
         case HeraldFieldConfig::FIELD_DIFF_CONTENT:
             return $this->loadContentDictionary();
         case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE:
             $packages = $this->loadAffectedPackages();
             return mpull($packages, 'getPHID');
         case HeraldFieldConfig::FIELD_AFFECTED_PACKAGE_OWNER:
             $packages = $this->loadAffectedPackages();
             $owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
             return mpull($owners, 'getUserPHID');
         default:
             throw new Exception("Invalid field '{$field}'.");
     }
 }