Page MenuHomePhabricator

D8429.diff
No OneTemporary

D8429.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -538,6 +538,7 @@
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
+ 'DiffusionGitFileContentQueryTestCase' => 'applications/diffusion/query/__tests__/DiffusionGitFileContentQueryTestCase.php',
'DiffusionGitRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionGitRawDiffQuery.php',
'DiffusionGitRequest' => 'applications/diffusion/request/DiffusionGitRequest.php',
'DiffusionGitResponse' => 'applications/diffusion/response/DiffusionGitResponse.php',
@@ -3105,6 +3106,7 @@
'DiffusionFileContentQuery' => 'DiffusionQuery',
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
+ 'DiffusionGitFileContentQueryTestCase' => 'PhabricatorTestCase',
'DiffusionGitRawDiffQuery' => 'DiffusionRawDiffQuery',
'DiffusionGitRequest' => 'DiffusionRequest',
'DiffusionGitResponse' => 'AphrontResponse',
Index: src/applications/diffusion/query/__tests__/DiffusionGitFileContentQueryTestCase.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/query/__tests__/DiffusionGitFileContentQueryTestCase.php
@@ -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();');
+ }
+}
Index: src/applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php
===================================================================
--- src/applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php
+++ src/applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php
@@ -32,6 +32,10 @@
}
protected function tokenizeLine($line) {
+ return self::match($line);
+ }
+
+ public static function match($line) {
$m = array();
// sample lines:
//
@@ -41,7 +45,7 @@
// 8220d5d54f6d5d5552a636576cbe9c35f15b65b2
// (Andrew Gallagher 2010-12-03 324)
// // 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);
$rev_id = $m[1];
$author = $m[2];

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 25, 6:10 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7311456
Default Alt Text
D8429.diff (3 KB)

Event Timeline