1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

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
This commit is contained in:
Andrew Gallagher 2011-06-06 16:08:49 -07:00
parent acdb215310
commit b8194202e6
2 changed files with 11 additions and 5 deletions

View file

@ -160,7 +160,7 @@ class DiffusionBrowseFileController extends DiffusionController {
$rev = $rev_list[$k]; $rev = $rev_list[$k];
$author = $blame_dict[$rev]['author']; $author = $blame_dict[$rev]['author'];
$rows[] = $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( $corpus = phutil_render_tag(
@ -269,8 +269,8 @@ class DiffusionBrowseFileController extends DiffusionController {
$blame_info = $blame_info =
$prev_link . $prev_link .
'<th style="background: '.$color. '<th style="background: '.$color.
'; width: 9em;">'.$revision_link.'</th>'. '; width: 12em;">'.$revision_link.'</th>'.
'<th style="background: '.$color. '<th style="background: '.$color.'; width: 12em'.
'; font-weight: normal; color: #333;">'.$author_link.'</th>'; '; font-weight: normal; color: #333;">'.$author_link.'</th>';
$last_rev = $rev; $last_rev = $rev;
} }

View file

@ -49,10 +49,16 @@ final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery {
protected function tokenizeLine($line) { protected function tokenizeLine($line) {
$m = array(); $m = array();
// sample line: // sample lines:
//
// d1b4fcdd2a7c8c0f8cbdd01ca839d992135424dc // d1b4fcdd2a7c8c0f8cbdd01ca839d992135424dc
// ( hzhao 2009-05-01 202)function print(); // ( 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]; $rev_id = $m[1];
$author = $m[2]; $author = $m[2];
$text = idx($m, 3); $text = idx($m, 3);