mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Merge branch 'master' of github.com:facebook/phabricator
This commit is contained in:
commit
dbb01cfe63
8 changed files with 252 additions and 22 deletions
|
@ -78,6 +78,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
||||||
'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision',
|
'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision',
|
||||||
'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find',
|
'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find',
|
||||||
|
'ConduitAPI_differential_getalldiffs_Method' => 'applications/conduit/method/differential/getalldiffs',
|
||||||
'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage',
|
'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage',
|
||||||
'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths',
|
'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths',
|
||||||
'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff',
|
'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff',
|
||||||
|
@ -88,6 +89,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision',
|
'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision',
|
||||||
'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits',
|
'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits',
|
||||||
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload',
|
||||||
|
'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners',
|
||||||
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
|
'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find',
|
||||||
'ConduitAPI_user_whoami_Method' => 'applications/conduit/method/user/whoami',
|
'ConduitAPI_user_whoami_Method' => 'applications/conduit/method/user/whoami',
|
||||||
'ConduitException' => 'applications/conduit/protocol/exception',
|
'ConduitException' => 'applications/conduit/protocol/exception',
|
||||||
|
@ -525,6 +527,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod',
|
||||||
|
'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod',
|
||||||
|
@ -535,6 +538,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||||
|
'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_user_whoami_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_user_whoami_Method' => 'ConduitAPIMethod',
|
||||||
'DarkConsoleConfigPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleConfigPlugin' => 'DarkConsolePlugin',
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConduitAPI_differential_getalldiffs_Method extends ConduitAPIMethod {
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return "Load all diffs for given revisions from Differential.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineParamTypes() {
|
||||||
|
return array(
|
||||||
|
'revision_ids' => 'required list<int>',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'dict';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineErrorTypes() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
$results = array();
|
||||||
|
$revision_ids = $request->getValue('revision_ids');
|
||||||
|
|
||||||
|
if (!$revision_ids) {
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
$diffs = id(new DifferentialDiff())->loadAllWhere(
|
||||||
|
'revisionID IN (%Ld)',
|
||||||
|
$revision_ids);
|
||||||
|
|
||||||
|
foreach ($diffs as $diff) {
|
||||||
|
$results[] = array(
|
||||||
|
'revision_id' => $diff->getRevisionID(),
|
||||||
|
'diff_id' => $diff->getID(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('ConduitAPI_differential_getalldiffs_Method.php');
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConduitAPI_path_getowners_Method extends ConduitAPIMethod {
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return "Find owners package given its name";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineParamTypes() {
|
||||||
|
return array(
|
||||||
|
'repositoryCallsign' => 'required nonempty string',
|
||||||
|
'path' => 'required nonempty string'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'array of packages containing phid, primary_owner (phid=>username),'.
|
||||||
|
'owners(array of phid=>username)';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineErrorTypes() {
|
||||||
|
return array(
|
||||||
|
'ERR_REP_NOT_FOUND' => 'The repository callsign is not recognized',
|
||||||
|
'ERR_PATH_NOT_FOUND' => 'The specified path is not known to any package',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
|
||||||
|
$repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s',
|
||||||
|
$request->getValue('repositoryCallsign'));
|
||||||
|
|
||||||
|
if (empty($repository)) {
|
||||||
|
throw new ConduitException('ERR_REP_NOT_FOUND');
|
||||||
|
}
|
||||||
|
|
||||||
|
$packages = PhabricatorOwnersPackage::loadOwningPackages(
|
||||||
|
$repository, $request->getValue('path'));
|
||||||
|
if (empty($packages)) {
|
||||||
|
throw new ConduitException('ERR_PATH_NOT_FOUND');
|
||||||
|
}
|
||||||
|
|
||||||
|
$owner = new PhabricatorOwnersOwner();
|
||||||
|
$user = new PhabricatorUser();
|
||||||
|
$result = array();
|
||||||
|
foreach ($packages as $package) {
|
||||||
|
$p_result = array();
|
||||||
|
$p_result['phid'] = $package->getID();
|
||||||
|
$primary_owner_phid = $package->getPrimaryOwnerPHID();
|
||||||
|
if (!empty($primary_owner_phid)) {
|
||||||
|
$p_user = $user->loadOneWhere('phid = %s',
|
||||||
|
$primary_owner_phid);
|
||||||
|
$p_result['primaryOwner'] = $p_user->getPhid();
|
||||||
|
}
|
||||||
|
|
||||||
|
$p_owners = $owner->loadAllForPackages(array($package));
|
||||||
|
$p_users = $user->loadAllWhere('phid IN (%Ls)',
|
||||||
|
mpull($p_owners, 'getUserPHID'));
|
||||||
|
|
||||||
|
$p_result['owners'] = array_values(mpull($p_users, 'getPhid'));
|
||||||
|
|
||||||
|
$result[] = $p_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/applications/conduit/method/path/getowners/__init__.php
Normal file
19
src/applications/conduit/method/path/getowners/__init__.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||||
|
phutil_require_module('phabricator', 'applications/owners/storage/owner');
|
||||||
|
phutil_require_module('phabricator', 'applications/owners/storage/package');
|
||||||
|
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||||
|
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('ConduitAPI_path_getowners_Method.php');
|
|
@ -79,29 +79,65 @@ class PhabricatorOwnersPackage extends PhabricatorOwnersDAO {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
$trailing_slash = preg_match('@/$@', $path) ? '/' : '';
|
$fragments += self::splitPath($path);
|
||||||
$path = trim($path, '/');
|
}
|
||||||
$parts = explode('/', $path);
|
|
||||||
while (count($parts)) {
|
return self::loadPackagesForPaths($repository, array_keys($fragments));
|
||||||
$fragments['/'.implode('/', $parts).$trailing_slash] = true;
|
}
|
||||||
$trailing_slash = '/';
|
|
||||||
array_pop($parts);
|
public static function loadOwningPackages($repository, $path) {
|
||||||
|
if (empty($path)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$fragments = self::splitPath($path);
|
||||||
|
return self::loadPackagesForPaths($repository, array_keys($fragments), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function loadPackagesForPaths(
|
||||||
|
PhabricatorRepository $repository,
|
||||||
|
array $paths,
|
||||||
|
$limit = 0) {
|
||||||
|
$package = new PhabricatorOwnersPackage();
|
||||||
|
$path = new PhabricatorOwnersPath();
|
||||||
|
$conn = $package->establishConnection('r');
|
||||||
|
|
||||||
|
$repository_clause = qsprintf($conn, 'AND p.repositoryPHID = %s',
|
||||||
|
$repository->getPHID());
|
||||||
|
|
||||||
|
$limit_clause = '';
|
||||||
|
if (!empty($limit)) {
|
||||||
|
$limit_clause = qsprintf($conn, 'LIMIT %d', $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = queryfx_all(
|
||||||
|
$conn,
|
||||||
|
'SELECT pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id
|
||||||
|
WHERE p.path IN (%Ls) %Q ORDER BY LENGTH(p.path) DESC %Q',
|
||||||
|
$package->getTableName(),
|
||||||
|
$path->getTableName(),
|
||||||
|
$paths,
|
||||||
|
$repository_clause,
|
||||||
|
$limit_clause);
|
||||||
|
|
||||||
|
$ids = ipull($data, 'id');
|
||||||
|
|
||||||
|
if (empty($ids)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = array();
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
if (empty($order[$id])) {
|
||||||
|
$order[$id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$package = new PhabricatorOwnersPackage();
|
$packages = $package->loadAllWhere('id in (%Ld)', array_keys($order));
|
||||||
$path = new PhabricatorOwnersPath();
|
|
||||||
$data = queryfx_all(
|
|
||||||
$package->establishConnection('r'),
|
|
||||||
'SELECT pkg.* FROM %T pkg JOIN %T p ON p.packageID = pkg.id
|
|
||||||
WHERE p.repositoryPHID = %s
|
|
||||||
AND p.path IN (%Ls)',
|
|
||||||
$package->getTableName(),
|
|
||||||
$path->getTableName(),
|
|
||||||
$repository->getPHID(),
|
|
||||||
array_keys($fragments));
|
|
||||||
|
|
||||||
return $package->loadAllFromArray($data);
|
$packages = array_select_keys($packages, array_keys($order));
|
||||||
|
|
||||||
|
return $packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
|
@ -167,4 +203,16 @@ class PhabricatorOwnersPackage extends PhabricatorOwnersDAO {
|
||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function splitPath($path) {
|
||||||
|
$result = array();
|
||||||
|
$trailing_slash = preg_match('@/$@', $path) ? '/' : '';
|
||||||
|
$path = trim($path, '/');
|
||||||
|
$parts = explode('/', $path);
|
||||||
|
while (count($parts)) {
|
||||||
|
$result['/'.implode('/', $parts).$trailing_slash] = true;
|
||||||
|
$trailing_slash = '/';
|
||||||
|
array_pop($parts);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/owners/storage/base');
|
||||||
phutil_require_module('phabricator', 'applications/owners/storage/owner');
|
phutil_require_module('phabricator', 'applications/owners/storage/owner');
|
||||||
phutil_require_module('phabricator', 'applications/owners/storage/path');
|
phutil_require_module('phabricator', 'applications/owners/storage/path');
|
||||||
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
||||||
|
phutil_require_module('phabricator', 'storage/qsprintf');
|
||||||
phutil_require_module('phabricator', 'storage/queryfx');
|
phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
|
@ -32,13 +32,12 @@ class PhabricatorRemarkupRuleImageMacro
|
||||||
$this->images[$row->getName()] = $row->getFilePHID();
|
$this->images[$row->getName()] = $row->getFilePHID();
|
||||||
}
|
}
|
||||||
$this->images[self::RANDOM_IMAGE_NAME] = '';
|
$this->images[self::RANDOM_IMAGE_NAME] = '';
|
||||||
|
$this->hash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function apply($text) {
|
public function apply($text) {
|
||||||
$this->hash = 0;
|
|
||||||
|
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'@\b([a-zA-Z0-9_\-]+)\b@U',
|
'@\b([a-zA-Z0-9_\-]+)\b@',
|
||||||
array($this, 'markupImageMacro'),
|
array($this, 'markupImageMacro'),
|
||||||
$text);
|
$text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue