Ejemplo n.º 1
0
 private function getDiffObj(ArcanistWorkflow $workflow)
 {
     $diffId = $workflow->getDiffID();
     // The diff information is not in the workflow object, so we need
     // to request it from Phabricator via the diffId. One "differential"
     // can have many "diffs", e.g. if you amend a commit or have
     // multipe ones for the same differential. The "revision"
     // refers to the whole differential.
     $this->writeOut(pht("Getting diff with ID %s ...", $diffId));
     // setup our query
     $conduit = $workflow->getConduit();
     $query = array("ids" => array($diffId));
     // This gives a key/value pair of results, e.g.:
     // 11 => { ... the diff object ... }
     // where "11" is the diffId
     $diffQueryResultArr = $conduit->callMethodSynchronous('differential.querydiffs', $query);
     $diffObj = null;
     if (array_key_exists($diffId, $diffQueryResultArr)) {
         $diffObj = $diffQueryResultArr[$diffId];
     } else {
         $this->writeErr("Did not find diff in query result from Phabricate");
         $errorMessage = HookUtils::getStringValueFromObj("errorMessage", $diffQueryResultArr);
         if ($errorMessage) {
             $this->writeErr($errorMessage);
         }
     }
     return $diffObj;
 }
Ejemplo n.º 2
0
 public function doHook(ArcanistWorkflow $workflow)
 {
     $dict = $workflow->getRevisionDict();
     if ($dict) {
         // Here we actually have a differential object, aka a revision.
         $revisionId = HookUtils::getStringValueFromObj(self::PH_ID, $dict);
         $topicBranch = HookUtils::getStringValueFromObj(self::PH_BRANCH, $dict);
         if ($revisionId && $topicBranch) {
             $remoteBranchName = HookUtils::createRemoteBranchName($revisionId, $topicBranch);
             if (HookUtils::shouldSkipCi($dict)) {
                 $this->writeOut(pht("Saw skip ci message in commit, skipping delete of remote branch %s\n", $remoteBranchName));
             } else {
                 // Here is the majicks:
                 $this->deleteRemoteBranch($remoteBranchName);
             }
         }
     }
 }