From b8194202e68b8f91349ea50f641a3688632dcd29 Mon Sep 17 00:00:00 2001 From: Andrew Gallagher Date: Mon, 6 Jun 2011 16:08:49 -0700 Subject: [PATCH] diffusion: fix git log author name parsing Summary: The current git log parsing wouldn't work correctly when space appeared in the author name. This diff fixes to regex to work with multi-word author names and increases the author column width when viewing blame info to accound for larger author names. Test Plan: viewed file with blame info in diffusion where author name contained multiple words Reviewed By: jungejason Reviewers: jungejason, epriestley CC: aran, rm, jungejason Differential Revision: 399 --- .../controller/file/DiffusionBrowseFileController.php | 6 +++--- .../filecontent/git/DiffusionGitFileContentQuery.php | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php index 50eeba0f52..e6ba597483 100644 --- a/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php @@ -160,7 +160,7 @@ class DiffusionBrowseFileController extends DiffusionController { $rev = $rev_list[$k]; $author = $blame_dict[$rev]['author']; $rows[] = - sprintf("%-10s %-15s %s", substr($rev, 0, 7), $author, $line); + sprintf("%-10s %-20s %s", substr($rev, 0, 7), $author, $line); } $corpus = phutil_render_tag( @@ -269,8 +269,8 @@ class DiffusionBrowseFileController extends DiffusionController { $blame_info = $prev_link . ''.$revision_link.''. - ''.$revision_link.''. + ''.$author_link.''; $last_rev = $rev; } diff --git a/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php b/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php index 9176fbfebb..5f9889a448 100644 --- a/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php +++ b/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php @@ -49,10 +49,16 @@ final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery { protected function tokenizeLine($line) { $m = array(); - // sample line: + // sample lines: + // // d1b4fcdd2a7c8c0f8cbdd01ca839d992135424dc // ( hzhao 2009-05-01 202)function print(); - preg_match('/^\s*?(\S+?)\s*\(\s*(\S+)\s+\S+\s+\d+\)(.*)?$/', $line, $m); + // + // 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+\)(.*)?$/', + $line, $m); $rev_id = $m[1]; $author = $m[2]; $text = idx($m, 3);