1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Fix a dirname() edge case in Diffusion

Summary:
dirname('x') returns '.', not '/'; this caused some issues for repositories with
files at the root.

There are some cases in the parsers where I should probably swap this out too
but I'll wait until I'm doing some more rigorous testing since that stuff is a
bit fragile and this fixes an immediate issue.

Test Plan: Ran unit tests. Viewed a file at root level in a test repository.

Reviewers: jungejason, nh, tuomaspelkonen, aran

Reviewed By: nh

CC: aran, nh

Differential Revision: 932
This commit is contained in:
epriestley 2011-09-14 11:23:39 -07:00
parent 43a3f4d234
commit b64f252f8b
5 changed files with 58 additions and 1 deletions

View file

@ -262,6 +262,7 @@ phutil_register_library_map(array(
'DiffusionPathChangeQuery' => 'applications/diffusion/query/pathchange/base',
'DiffusionPathCompleteController' => 'applications/diffusion/controller/pathcomplete',
'DiffusionPathIDQuery' => 'applications/diffusion/query/pathid/base',
'DiffusionPathQueryTestCase' => 'applications/diffusion/query/pathid/base/__tests__',
'DiffusionPathValidateController' => 'applications/diffusion/controller/pathvalidate',
'DiffusionRepositoryController' => 'applications/diffusion/controller/repository',
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
@ -918,6 +919,7 @@ phutil_register_library_map(array(
'DiffusionHomeController' => 'DiffusionController',
'DiffusionLastModifiedController' => 'DiffusionController',
'DiffusionPathCompleteController' => 'DiffusionController',
'DiffusionPathQueryTestCase' => 'PhabricatorTestCase',
'DiffusionPathValidateController' => 'DiffusionController',
'DiffusionRepositoryController' => 'DiffusionController',
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',

View file

@ -36,7 +36,7 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
$conn_r = $repository->establishConnection('r');
$parent_path = dirname($path);
$parent_path = DiffusionPathIDQuery::getParentPath($path);
$path_query = new DiffusionPathIDQuery(
array(
$path,

View file

@ -53,4 +53,9 @@ final class DiffusionPathIDQuery {
return '/'.trim($path, '/');
}
public static function getParentPath($path) {
$path = self::normalizePath($path);
return dirname($path);
}
}

View file

@ -0,0 +1,37 @@
<?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.
*/
final class DiffusionPathQueryTestCase extends PhabricatorTestCase {
public function testParentEdgeCases() {
$this->assertEqual(
'/',
DiffusionPathIDQuery::getParentPath('/'),
'Parent of /');
$this->assertEqual(
'/',
DiffusionPathIDQuery::getParentPath('x.txt'),
'Parent of x.txt');
$this->assertEqual(
'/a',
DiffusionPathIDQuery::getParentPath('/a/b'),
'Parent of /a/b');
}
}

View file

@ -0,0 +1,13 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/diffusion/query/pathid/base');
phutil_require_module('phabricator', 'infrastructure/testing/testcase');
phutil_require_source('DiffusionPathQueryTestCase.php');