@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Start changing DiffusionCommitController to use identities

Summary: Depends on D19491.

Test Plan: Viewed some commits where the identity was mapped to a user and another that wasn't; saw the header render either a link to the user or the identity object.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D19492

+87 -24
+8 -24
src/applications/diffusion/controller/DiffusionCommitController.php
··· 46 46 ->needCommitData(true) 47 47 ->needAuditRequests(true) 48 48 ->setLimit(100) 49 + ->needIdentities(true) 49 50 ->execute(); 50 51 51 52 $multiple_results = count($commits) > 1; ··· 504 505 505 506 $phids = $edge_query->getDestinationPHIDs(array($commit_phid)); 506 507 507 - if ($data->getCommitDetail('authorPHID')) { 508 - $phids[] = $data->getCommitDetail('authorPHID'); 509 - } 508 + 510 509 if ($data->getCommitDetail('reviewerPHID')) { 511 510 $phids[] = $data->getCommitDetail('reviewerPHID'); 512 511 } 513 - if ($data->getCommitDetail('committerPHID')) { 514 - $phids[] = $data->getCommitDetail('committerPHID'); 515 - } 512 + 513 + $phids[] = $commit->getCommitterDisplayPHID(); 514 + $phids[] = $commit->getAuthorDisplayPHID(); 516 515 517 516 // NOTE: We should never normally have more than a single push log, but 518 517 // it can occur naturally if a commit is pushed, then the branch it was ··· 573 572 } 574 573 } 575 574 576 - $author_phid = $data->getCommitDetail('authorPHID'); 577 - $author_name = $data->getAuthorName(); 578 575 $author_epoch = $data->getCommitDetail('authorEpoch'); 579 576 580 577 $committed_info = id(new PHUIStatusItemView()) 581 - ->setNote(phabricator_datetime($commit->getEpoch(), $viewer)); 582 - 583 - $committer_phid = $data->getCommitDetail('committerPHID'); 584 - $committer_name = $data->getCommitDetail('committer'); 585 - if ($committer_phid) { 586 - $committed_info->setTarget($handles[$committer_phid]->renderLink()); 587 - } else if (strlen($committer_name)) { 588 - $committed_info->setTarget($committer_name); 589 - } else if ($author_phid) { 590 - $committed_info->setTarget($handles[$author_phid]->renderLink()); 591 - } else if (strlen($author_name)) { 592 - $committed_info->setTarget($author_name); 593 - } 578 + ->setNote(phabricator_datetime($commit->getEpoch(), $viewer)) 579 + ->setTarget($commit->renderAnyCommitter($viewer, $handles)); 594 580 595 581 $committed_list = new PHUIStatusListView(); 596 582 $committed_list->addItem($committed_info); ··· 716 702 return null; 717 703 } 718 704 719 - $author_phid = $data->getCommitDetail('authorPHID'); 705 + $author_phid = $commit->getAuthorDisplayPHID(); 720 706 $author_name = $data->getAuthorName(); 721 707 $author_epoch = $data->getCommitDetail('authorEpoch'); 722 708 $date = null; ··· 748 734 ->setImage($image_uri) 749 735 ->setImageHref($image_href) 750 736 ->setContent($content); 751 - 752 737 } 753 - 754 738 755 739 private function buildComments(PhabricatorRepositoryCommit $commit) { 756 740 $timeline = $this->buildTransactionTimeline(
+71
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 439 439 return $repository->formatCommitName($identifier, $local = true); 440 440 } 441 441 442 + /** 443 + * Make a strong effort to find a way to render this commit's committer. 444 + * This currently attempts to use @{PhabricatorRepositoryIdentity}, and 445 + * falls back to examining the commit detail information. After we force 446 + * the migration to using identities, update this method to remove the 447 + * fallback. See T12164 for details. 448 + */ 449 + public function renderAnyCommitter(PhabricatorUser $viewer, array $handles) { 450 + $committer = $this->renderCommitter($viewer, $handles); 451 + if ($committer) { 452 + return $committer; 453 + } 454 + 455 + return $this->renderAuthor($viewer, $handles); 456 + } 457 + 458 + public function renderCommitter(PhabricatorUser $viewer, array $handles) { 459 + $committer_phid = $this->getCommitterDisplayPHID(); 460 + if ($committer_phid) { 461 + return $handles[$committer_phid]->renderLink(); 462 + } 463 + 464 + $data = $this->getCommitData(); 465 + $committer_name = $data->getCommitDetail('committer'); 466 + if (strlen($committer_name)) { 467 + return $committer_name; 468 + } 469 + 470 + return null; 471 + } 472 + 473 + public function renderAuthor(PhabricatorUser $viewer, array $handles) { 474 + $author_phid = $this->getAuthorDisplayPHID(); 475 + if ($author_phid) { 476 + return $handles[$author_phid]->renderLink(); 477 + } 478 + 479 + $data = $this->getCommitData(); 480 + $author_name = $data->getAuthorName(); 481 + if (strlen($author_name)) { 482 + return $author_name; 483 + } 484 + 485 + return null; 486 + } 487 + 488 + public function hasCommitterIdentity() { 489 + return ($this->getCommitterIdentity() !== null); 490 + } 491 + 492 + public function hasAuthorIdentity() { 493 + return ($this->getAuthorIdentity() !== null); 494 + } 495 + 496 + public function getCommitterDisplayPHID() { 497 + if ($this->hasCommitterIdentity()) { 498 + return $this->getCommitterIdentity()->getIdentityDisplayPHID(); 499 + } 500 + 501 + $data = $this->getCommitData(); 502 + return $data->getCommitDetail('committerPHID'); 503 + } 504 + 505 + public function getAuthorDisplayPHID() { 506 + if ($this->hasAuthorIdentity()) { 507 + return $this->getAuthorIdentity()->getIdentityDisplayPHID(); 508 + } 509 + 510 + $data = $this->getCommitData(); 511 + return $data->getCommitDetail('authorPHID'); 512 + } 442 513 443 514 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 444 515
+8
src/applications/repository/storage/PhabricatorRepositoryIdentity.php
··· 78 78 return ($this->currentEffectiveUserPHID != null); 79 79 } 80 80 81 + public function getIdentityDisplayPHID() { 82 + if ($this->hasEffectiveUser()) { 83 + return $this->getCurrentEffectiveUserPHID(); 84 + } else { 85 + return $this->getPHID(); 86 + } 87 + } 88 + 81 89 public function save() { 82 90 if ($this->manuallySetUserPHID) { 83 91 $this->currentEffectiveUserPHID = $this->manuallySetUserPHID;