mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Allow parenthesis in author name
Summary: We have a dozen users who has `(...)` in their 'real name', like 'Jimmy (He) Zhang', and it's causing the diffusion file browser problems when blame is enabled. The parser does not expect those parenthesis and the lines of code will be empty if they were last touched by a user like that. Test Plan: Try it Reviewers: wez, lifeihuang, JoelB, #blessed_reviewers, epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D8429
This commit is contained in:
parent
270916a26e
commit
81d9935efe
3 changed files with 39 additions and 1 deletions
|
@ -538,6 +538,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
|
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
|
||||||
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
|
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
|
||||||
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
||||||
|
'DiffusionGitFileContentQueryTestCase' => 'applications/diffusion/query/__tests__/DiffusionGitFileContentQueryTestCase.php',
|
||||||
'DiffusionGitRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionGitRawDiffQuery.php',
|
'DiffusionGitRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionGitRawDiffQuery.php',
|
||||||
'DiffusionGitRequest' => 'applications/diffusion/request/DiffusionGitRequest.php',
|
'DiffusionGitRequest' => 'applications/diffusion/request/DiffusionGitRequest.php',
|
||||||
'DiffusionGitResponse' => 'applications/diffusion/response/DiffusionGitResponse.php',
|
'DiffusionGitResponse' => 'applications/diffusion/response/DiffusionGitResponse.php',
|
||||||
|
@ -3105,6 +3106,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
||||||
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
|
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
|
||||||
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
|
'DiffusionGitFileContentQueryTestCase' => 'PhabricatorTestCase',
|
||||||
'DiffusionGitRawDiffQuery' => 'DiffusionRawDiffQuery',
|
'DiffusionGitRawDiffQuery' => 'DiffusionRawDiffQuery',
|
||||||
'DiffusionGitRequest' => 'DiffusionRequest',
|
'DiffusionGitRequest' => 'DiffusionRequest',
|
||||||
'DiffusionGitResponse' => 'AphrontResponse',
|
'DiffusionGitResponse' => 'AphrontResponse',
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionGitFileContentQueryTestCase extends PhabricatorTestCase {
|
||||||
|
|
||||||
|
public function testAuthorName() {
|
||||||
|
// A normal case - no parenthesis in user name
|
||||||
|
$result = DiffusionGitFileContentQuery::match(
|
||||||
|
'8220d5d54f6d5d5552a636576cbe9c35f15b65b2 '.
|
||||||
|
'(Andrew Gallagher 2010-12-03 324) $somevar = $this->call()');
|
||||||
|
$this->assertEqual($result[0], '8220d5d54f6d5d5552a636576cbe9c35f15b65b2');
|
||||||
|
$this->assertEqual($result[1], 'Andrew Gallagher');
|
||||||
|
$this->assertEqual($result[2], ' $somevar = $this->call()');
|
||||||
|
|
||||||
|
// User name like 'Jimmy (He) Zhang'
|
||||||
|
$result = DiffusionGitFileContentQuery::match(
|
||||||
|
'8220d5d54f6d5d5552a636576cbe9c35f15b65b2 '.
|
||||||
|
'( Jimmy (He) Zhang 2013-10-11 5) '.
|
||||||
|
'code(); "(string literal 9999-99-99 2)"; more_code();');
|
||||||
|
$this->assertEqual($result[1], 'Jimmy (He) Zhang');
|
||||||
|
$this->assertEqual($result[2],
|
||||||
|
' code(); "(string literal 9999-99-99 2)"; more_code();');
|
||||||
|
|
||||||
|
// User name like 'Scott Shapiro (Ads Product Marketing)'
|
||||||
|
$result = DiffusionGitFileContentQuery::match(
|
||||||
|
'8220d5d54f6d5d5552a636576cbe9c35f15b65b2 '.
|
||||||
|
'( Scott Shapiro (Ads Product Marketing) 2013-10-11 5) '.
|
||||||
|
'code(); "(string literal 9999-99-99 2)"; more_code();');
|
||||||
|
$this->assertEqual($result[1], 'Scott Shapiro (Ads Product Marketing)');
|
||||||
|
$this->assertEqual($result[2],
|
||||||
|
' code(); "(string literal 9999-99-99 2)"; more_code();');
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,10 @@ final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tokenizeLine($line) {
|
protected function tokenizeLine($line) {
|
||||||
|
return self::match($line);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function match($line) {
|
||||||
$m = array();
|
$m = array();
|
||||||
// sample lines:
|
// sample lines:
|
||||||
//
|
//
|
||||||
|
@ -41,7 +45,7 @@ final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery {
|
||||||
// 8220d5d54f6d5d5552a636576cbe9c35f15b65b2
|
// 8220d5d54f6d5d5552a636576cbe9c35f15b65b2
|
||||||
// (Andrew Gallagher 2010-12-03 324)
|
// (Andrew Gallagher 2010-12-03 324)
|
||||||
// // Add the lines for trailing context
|
// // Add the lines for trailing context
|
||||||
preg_match('/^\s*?(\S+?)\s*\(\s*([^)]*)\s+\d{4}-\d{2}-\d{2}\s+\d+\)(.*)?$/',
|
preg_match('/^\s*?(\S+?)\s*\(\s*(.*?)\s+\d{4}-\d{2}-\d{2}\s+\d+\)(.*)?$/',
|
||||||
$line, $m);
|
$line, $m);
|
||||||
$rev_id = $m[1];
|
$rev_id = $m[1];
|
||||||
$author = $m[2];
|
$author = $m[2];
|
||||||
|
|
Loading…
Reference in a new issue