public function processRequest() { $drequest = $this->getDiffusionRequest(); $request = $this->getRequest(); $viewer = $request->getUser(); $repository = $drequest->getRepository(); $pager = new AphrontPagerView(); $pager->setURI($request->getRequestURI(), 'offset'); $pager->setOffset($request->getInt('offset')); // TODO: Add support for branches that contain commit $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('offset' => $pager->getOffset(), 'limit' => $pager->getPageSize() + 1)); $branches = $pager->sliceResults($branches); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $content = null; if (!$branches) { $content = $this->renderStatusMessage(pht('No Branches'), pht('This repository has no branches.')); } else { $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($branches, 'getCommitIdentifier'))->withRepository($repository)->execute(); $view = id(new DiffusionBranchTableView())->setUser($viewer)->setBranches($branches)->setCommits($commits)->setDiffusionRequest($drequest); $panel = id(new AphrontPanelView())->setNoBackground(true)->appendChild($view)->appendChild($pager); $content = $panel; } $crumbs = $this->buildCrumbs(array('branches' => true)); return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(pht('Branches'), 'r' . $repository->getCallsign()), 'device' => false)); }
public function handleRequest(AphrontRequest $request) { $response = $this->loadDiffusionContext(); if ($response) { return $response; } $viewer = $this->getViewer(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $pager = id(new PHUIPagerView())->readFromRequest($request); // TODO: Add support for branches that contain commit $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('offset' => $pager->getOffset(), 'limit' => $pager->getPageSize() + 1)); $branches = $pager->sliceResults($branches); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $content = null; if (!$branches) { $content = $this->renderStatusMessage(pht('No Branches'), pht('This repository has no branches.')); } else { $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($branches, 'getCommitIdentifier'))->withRepository($repository)->execute(); $view = id(new DiffusionBranchTableView())->setUser($viewer)->setBranches($branches)->setCommits($commits)->setDiffusionRequest($drequest); $panel = id(new PHUIObjectBoxView())->setHeaderText(pht('Branches'))->setTable($view); $content = $panel; } $crumbs = $this->buildCrumbs(array('branches' => true)); $pager_box = $this->renderTablePagerBox($pager); return $this->newPage()->setTitle(array(pht('Branches'), $repository->getDisplayName()))->setCrumbs($crumbs)->appendChild(array($content, $pager_box)); }
public function handleRequest(AphrontRequest $request) { $response = $this->loadDiffusionContext(); if ($response) { return $response; } $viewer = $this->getViewer(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $pager = id(new PHUIPagerView())->readFromRequest($request); $params = array('offset' => $pager->getOffset(), 'limit' => $pager->getPageSize() + 1); $contains = $drequest->getSymbolicCommit(); if (strlen($contains)) { $params['contains'] = $contains; } $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', $params); $branches = $pager->sliceResults($branches); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $content = null; if (!$branches) { $content = $this->renderStatusMessage(pht('No Branches'), pht('This repository has no branches.')); } else { $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($branches, 'getCommitIdentifier'))->withRepository($repository)->execute(); $table = id(new DiffusionBranchTableView())->setUser($viewer)->setBranches($branches)->setCommits($commits)->setDiffusionRequest($drequest); $content = id(new PHUIObjectBoxView())->setHeaderText($repository->getName())->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setTable($table); } $crumbs = $this->buildCrumbs(array('branches' => true)); $crumbs->setBorder(true); $pager_box = $this->renderTablePagerBox($pager); $header = id(new PHUIHeaderView())->setHeader(pht('Branches'))->setHeaderIcon('fa-code-fork'); $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($content, $pager_box)); return $this->newPage()->setTitle(array(pht('Branches'), $repository->getDisplayName()))->setCrumbs($crumbs)->appendChild(array($view)); }
public function getHeraldFieldValue($object) { $commit = $object; $repository = $object->getRepository(); $params = array('callsign' => $repository->getCallsign(), 'contains' => $commit->getCommitIdentifier()); $result = id(new ConduitCall('diffusion.branchquery', $params))->setUser(PhabricatorUser::getOmnipotentUser())->execute(); $refs = DiffusionRepositoryRef::loadAllFromDictionaries($result); return mpull($refs, 'getShortName'); }
public function buildApplicationTransactionMailBody(PhabricatorApplicationTransaction $xaction, PhabricatorMetaMTAMailBody $body) { $params = array('contains' => $this->getObject()->getCommitIdentifier(), 'callsign' => $this->getObject()->getRepository()->getCallsign()); $branches_raw = id(new ConduitCall('diffusion.branchquery', $params))->setUser($this->getViewer())->execute(); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches_raw); if (!$branches) { return; } $branch_names = mpull($branches, 'getShortName'); sort($branch_names); $body->addTextSection(pht('BRANCHES'), implode(', ', $branch_names)); }
public function updateTransactionMailBody(PhabricatorMetaMTAMailBody $body, PhabricatorApplicationTransactionEditor $editor, array $xactions) { $params = array('contains' => $this->getObject()->getCommitIdentifier(), 'callsign' => $this->getObject()->getRepository()->getCallsign()); try { $branches_raw = id(new ConduitCall('diffusion.branchquery', $params))->setUser($this->getViewer())->execute(); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches_raw); if (!$branches) { return; } $branch_names = mpull($branches, 'getShortName'); sort($branch_names); $branch_text = implode(', ', $branch_names); } catch (Exception $ex) { $branch_text = pht('<%s: %s>', get_class($ex), $ex->getMessage()); } $body->addTextSection(pht('BRANCHES'), $branch_text); }
public function processRequest() { $request = $this->getDiffusionRequest(); $branches = array(); try { $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('contains' => $request->getCommit())); } catch (ConduitException $ex) { if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') { throw $ex; } } $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $branch_links = array(); foreach ($branches as $branch) { $branch_links[] = phutil_tag('a', array('href' => $request->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()); } return id(new AphrontAjaxResponse())->setContent($branch_links ? implode(', ', $branch_links) : 'None'); }
protected function processDiffusionRequest(AphrontRequest $request) { $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); switch ($repository->getVersionControlSystem()) { case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: $branches = array(); break; default: $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('contains' => $drequest->getCommit())); break; } $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $branch_links = array(); foreach ($branches as $branch) { $branch_links[] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()); } return id(new AphrontAjaxResponse())->setContent($branch_links ? implode(', ', $branch_links) : pht('None')); }
public function handleRequest(AphrontRequest $request) { $response = $this->loadDiffusionContext(); if ($response) { return $response; } $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $branch_limit = 10; $branches = DiffusionRepositoryRef::loadAllFromDictionaries($this->callConduitWithDiffusionRequest('diffusion.branchquery', array('contains' => $drequest->getCommit(), 'limit' => $branch_limit + 1))); $has_more_branches = count($branches) > $branch_limit; $branches = array_slice($branches, 0, $branch_limit); $branch_links = array(); foreach ($branches as $branch) { $branch_links[] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()); } if ($has_more_branches) { $branch_links[] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'branches'))), pht("More Branches…")); } return id(new AphrontAjaxResponse())->setContent($branch_links ? implode(', ', $branch_links) : pht('None')); }
protected function processDiffusionRequest(AphrontRequest $request) { $drequest = $this->getDiffusionRequest(); $viewer = $request->getUser(); $repository = $drequest->getRepository(); $pager = new PHUIPagerView(); $pager->setURI($request->getRequestURI(), 'offset'); $pager->setOffset($request->getInt('offset')); // TODO: Add support for branches that contain commit $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('offset' => $pager->getOffset(), 'limit' => $pager->getPageSize() + 1)); $branches = $pager->sliceResults($branches); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $content = null; if (!$branches) { $content = $this->renderStatusMessage(pht('No Branches'), pht('This repository has no branches.')); } else { $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($branches, 'getCommitIdentifier'))->withRepository($repository)->execute(); $view = id(new DiffusionBranchTableView())->setUser($viewer)->setBranches($branches)->setCommits($commits)->setDiffusionRequest($drequest); $panel = id(new PHUIObjectBoxView())->setHeaderText(pht('Branches'))->setTable($view); $content = $panel; } $crumbs = $this->buildCrumbs(array('branches' => true)); return $this->buildApplicationPage(array($crumbs, $content, $pager), array('title' => array(pht('Branches'), $repository->getDisplayName()))); }
private function buildBranchListTable(DiffusionRequest $drequest) { $viewer = $this->getRequest()->getUser(); if ($drequest->getBranch() === null) { return null; } $limit = 15; $branches = $this->callConduitWithDiffusionRequest('diffusion.branchquery', array('closed' => false, 'limit' => $limit + 1)); if (!$branches) { return null; } $more_branches = count($branches) > $limit; $branches = array_slice($branches, 0, $limit); $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(mpull($branches, 'getCommitIdentifier'))->withRepository($drequest->getRepository())->execute(); $table = id(new DiffusionBranchTableView())->setUser($viewer)->setDiffusionRequest($drequest)->setBranches($branches)->setCommits($commits); $panel = new PHUIObjectBoxView(); $header = new PHUIHeaderView(); $header->setHeader(pht('Branches')); if ($more_branches) { $header->setSubHeader(pht('Showing %d branches.', $limit)); } $icon = id(new PHUIIconView())->setIconFont('fa-code-fork'); $button = new PHUIButtonView(); $button->setText(pht('Show All Branches')); $button->setTag('a'); $button->setIcon($icon); $button->setHref($drequest->generateURI(array('action' => 'branches'))); $header->addActionLink($button); $panel->setHeader($header); $panel->setTable($table); return $panel; }
public function shouldAutocloseRef(DiffusionRepositoryRef $ref) { if (!$ref->isBranch()) { return false; } return $this->shouldAutocloseBranch($ref->getShortName()); }
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); }