From a8e7e5276e82bda778d06f639e3c671aa8c84265 Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Thu, 26 Jun 2008 21:02:29 +0300 Subject: [PATCH] Shortlog logic cleanup. --- inc/functions.php | 23 +++++++++++++++++++++++ index.php | 25 ++----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 33c84b2..af01682 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -241,6 +241,29 @@ function git_ls_tree_part($project, $tree, $name) } /** + * Get shortlog entries for the given project. + */ +function handle_shortlog($project, $hash = 'HEAD') +{ + global $conf; + + $result = array(); + $revs = git_get_rev_list($project, $conf['summary_shortlog'], $hash); + foreach ($revs as $rev) { + $info = git_get_commit_info($project, $rev); + $result[] = array( + 'author' => $info['author_name'], + 'date' => strftime($conf['datetime'], $info['author_utcstamp']), + 'message' => $info['message'], + 'commit_id' => $rev, + 'tree' => $info['tree'], + ); + } + + return $result; +} + +/** * Fetch tags data, newest first. * * @param limit maximum number of tags to return diff --git a/index.php b/index.php index 33b023f..a591282 100644 --- a/index.php +++ b/index.php @@ -254,18 +254,7 @@ elseif ($action === 'shortlog') { $page['commit_id'] = $info['h']; $page['tree_id'] = $info['tree']; - // 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'], - ); - } + $page['shortlog'] = handle_shortlog($page['project'], $page['ref']); } elseif ($action === 'summary') { $template = 'summary'; @@ -276,17 +265,7 @@ elseif ($action === 'summary') { $page['commit_id'] = $info['h']; $page['tree_id'] = $info['tree']; - $revs = git_get_rev_list($page['project'], $conf['summary_shortlog']); - 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'], - ); - } + $page['shortlog'] = handle_shortlog($page['project']); $page['tags'] = handle_tags($page['project'], $conf['summary_tags']); -- 2.11.4.GIT