From 8893860eede49e1fb019415f93302ebf1b5bcbf7 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Wed, 14 May 2008 18:28:29 +0300 Subject: [PATCH] Simple shortlog page. --- doc/TODO | 1 - index.php | 24 ++++++++++++++-- templates/{summary.php => shortlog.php} | 49 ++++----------------------------- templates/summary.php | 28 +------------------ 4 files changed, 27 insertions(+), 75 deletions(-) copy templates/{summary.php => shortlog.php} (53%) diff --git a/doc/TODO b/doc/TODO index 945c3ee..3d08196 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,5 +1,4 @@ - shortlog page - - share subtemplate with summary - summary's shortlog title should link here - start from HEAD unless 'h' is provided, add a 'next' link that starts from the last commit? - blobs diff --git a/index.php b/index.php index 5163958..a19f395 100644 --- a/index.php +++ b/index.php @@ -101,11 +101,11 @@ function git_get_heads($project) return $heads; } -function git_get_rev_list($project, $max_count = null) +function git_get_rev_list($project, $max_count = null, $start = 'HEAD') { - $cmd = 'git rev-list HEAD'; + $cmd = "git rev-list $start"; if (!is_null($max_count)) { - $cmd = "git rev-list --max-count=$max_count HEAD"; + $cmd = "git rev-list --max-count=$max_count $start"; } return run_git($project, $cmd); @@ -304,6 +304,24 @@ elseif ($action === 'commitdiff') { $text = join("\n", run_git($page['project'], "git diff $hash^..$hash")); $page['diffdata'] = format_diff($text); } +elseif ($action === 'shortlog') { + $template = 'shortlog'; + $page['project'] = validate_project($_REQUEST['p']); + $page['ref'] = $_REQUEST['h']; // TODO validate + + // TODO merge the logic with 'summary' below + $revs = git_get_rev_list($page['project'], $conf['summary_shortlog'], $page['ref']); // TODO pass first rev as parameter + foreach ($revs as $rev) { + $info = git_get_commit_info($page['project'], $rev); + $page['shortlog'][] = array( + 'author' => $info['author_name'], + 'date' => strftime($conf['datetime'], $info['author_utcstamp']), + 'message' => $info['message'], + 'commit_id' => $rev, + 'tree' => $info['tree'], + ); + } +} elseif ($action === 'summary') { $template = 'summary'; $page['project'] = validate_project($_REQUEST['p']); diff --git a/templates/summary.php b/templates/shortlog.php similarity index 53% copy from templates/summary.php copy to templates/shortlog.php index 895ed7e..f8ffad5 100644 --- a/templates/summary.php +++ b/templates/shortlog.php @@ -11,6 +11,7 @@ \n"; echo "\t$l[date]\n"; @@ -23,54 +24,14 @@ foreach ($page['shortlog'] as $l) { echo "[ 'archive', 'p' => $page['project'], 'h' => $l['tree'], 't' => 'zip')) ."\">zip]"; echo "\n"; echo "\n"; + $page['lasthash'] = $l['commit_id']; } ?> -

Tags

- - - - - - - - - - -\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\n"; -} -?> - -
DateTagActions
$tag[date] 'shortlog', 'p' => $page['project'], 'h' => $tag['fullname'])) ."\">$tag[name]
- -

Heads

- - - - - - - - - - -\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\n"; + 'shortlog', 'p' => $page['project'], 'h' => $page['lasthash'])) ."\">More...

"; } ?> - -
DateBranchActions
$h[date] 'shortlog', 'p' => $page['project'], 'h' => $h['fullname'])) ."\">$h[name]
- diff --git a/templates/summary.php b/templates/summary.php index 895ed7e..ada24e8 100644 --- a/templates/summary.php +++ b/templates/summary.php @@ -1,32 +1,6 @@ -

Shortlog

- - - - - - - - - - -\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\n"; -} +require_once('templates/shortlog.php'); ?> - -
DateAuthorMessageActions
$l[date]$l[author] 'commit', 'p' => $page['project'], 'h' => $l['commit_id'])) ."\">$l[message]"; - echo "[ 'commitdiff', 'p' => $page['project'], 'h' => $l['commit_id'])) ."\">commitdiff]"; - echo "[ 'tree', 'p' => $page['project'], 'h' => $l['tree'])) ."\">tree]"; - echo "[ 'archive', 'p' => $page['project'], 'h' => $l['tree'], 't' => 'targz')) ."\">tar/gz]"; - echo "[ 'archive', 'p' => $page['project'], 'h' => $l['tree'], 't' => 'zip')) ."\">zip]"; - echo "

Tags

-- 2.11.4.GIT