diff --git a/scripts/gitadmin/rebuild_gitadmin.php b/scripts/gitadmin/rebuild_gitadmin.php index 83025a8edf..cccf2d2ae9 100755 --- a/scripts/gitadmin/rebuild_gitadmin.php +++ b/scripts/gitadmin/rebuild_gitadmin.php @@ -45,8 +45,8 @@ function handleSingleUserPHID( return array(); } - $keys = id(new PhabricatorUserSSHKey())->loadAllWhere( - 'userPHID = %s', + $keys = id(new PhabricatorAuthSSHKey())->loadAllWhere( + 'objectPHID = %s', $user->getPHID()); $members = array(); @@ -73,6 +73,27 @@ function handleSingleUserPHID( return $members; } +function handleCustomPolicy( + $keydir, $viewer, $policy, $system_keys, &$used_keys) { + $members = array(); + $rules = $policy->getRules(); + foreach ($rules as $rule) { + // Everyone is denied by default anyway + if ($rule['action'] == 'allow') { + if ($rule['rule'] == 'PhabricatorPolicyRuleUsers') { + foreach ($rule['value'] as $userPHID) { + $members = array_merge($members, + handleSingleUserPHID($keydir, $viewer, $userPHID, + $system_keys, $used_keys)); + } + } else { + /* pass */ + } + } + } + return $members; +} + // Parse repository and put it's members to the config file function handleSingleRepository( $keydir, $viewer, $repository, $all_repositories, $system_keys, @@ -82,11 +103,11 @@ function handleSingleRepository( $repository); $pushable = $policies[DiffusionPushCapability::CAPABILITY]; - $type = phid_get_type($pushable->getPHID()); + $type = $pushable->getType(); $members = array(); - if ($type == PhabricatorProjectProjectPHIDType::TYPECONST) { + if ($type == PhabricatorPolicyType::TYPE_PROJECT) { $project = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->needMembers(true) @@ -99,11 +120,12 @@ function handleSingleRepository( handleSingleUserPHID($keydir, $viewer, $memberPHID, $system_keys, $used_keys)); } - } else if ($type == PhabricatorPeopleUserPHIDType::TYPECONST) { + } else if ($type == PhabricatorPolicyType::TYPE_USER) { $members = handleSingleUserPHID( $keydir, $viewer, $pushable->getPHID(), $system_keys, $used_keys); - } else if ($type == PhabricatorPolicyPHIDTypePolicy::TYPECONST) { - /* pass */ + } else if ($type == PhabricatorPolicyType::TYPE_CUSTOM) { + $members = handleCustomPolicy( + $keydir, $viewer, $pushable, $system_keys, $used_keys); } else { /* pass */ }