Differential D20130 Diff 48067 src/applications/repository/worker/PhabricatorRepositoryCommitOwnersWorker.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/worker/PhabricatorRepositoryCommitOwnersWorker.php
Show First 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | private function isOwnerInvolved( | ||||
$revision) { | $revision) { | ||||
$owner_phids = PhabricatorOwnersOwner::loadAffiliatedUserPHIDs( | $owner_phids = PhabricatorOwnersOwner::loadAffiliatedUserPHIDs( | ||||
array( | array( | ||||
$package->getID(), | $package->getID(), | ||||
)); | )); | ||||
$owner_phids = array_fuse($owner_phids); | $owner_phids = array_fuse($owner_phids); | ||||
// For the purposes of deciding whether the owners were involved in the | |||||
// revision or not, consider a review by the package itself to count as | |||||
// involvement. This can happen when human reviewers force-accept on | |||||
// behalf of packages they don't own but have authority over. | |||||
$owner_phids[$package->getPHID()] = $package->getPHID(); | |||||
// If the commit author is identifiable and a package owner, they're | // If the commit author is identifiable and a package owner, they're | ||||
// involved. | // involved. | ||||
if ($author_phid) { | if ($author_phid) { | ||||
if (isset($owner_phids[$author_phid])) { | if (isset($owner_phids[$author_phid])) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
Show All 9 Lines | $accepted_statuses = array( | ||||
DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER, | DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER, | ||||
); | ); | ||||
$accepted_statuses = array_fuse($accepted_statuses); | $accepted_statuses = array_fuse($accepted_statuses); | ||||
$found_accept = false; | $found_accept = false; | ||||
foreach ($revision->getReviewers() as $reviewer) { | foreach ($revision->getReviewers() as $reviewer) { | ||||
$reviewer_phid = $reviewer->getReviewerPHID(); | $reviewer_phid = $reviewer->getReviewerPHID(); | ||||
// If this reviewer isn't a package owner, just ignore them. | // If this reviewer isn't a package owner or the package itself, | ||||
// just ignore them. | |||||
if (empty($owner_phids[$reviewer_phid])) { | if (empty($owner_phids[$reviewer_phid])) { | ||||
continue; | continue; | ||||
} | } | ||||
// If this reviewer accepted the revision and owns the package, we've | // If this reviewer accepted the revision and owns the package (or is | ||||
// found an involved owner. | // the package), we've found an involved owner. | ||||
if (isset($accepted_statuses[$reviewer->getReviewerStatus()])) { | if (isset($accepted_statuses[$reviewer->getReviewerStatus()])) { | ||||
$found_accept = true; | $found_accept = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if ($found_accept) { | if ($found_accept) { | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
} | } |