From 7c7685bee74397f9df6f78584385cfdb4bbeaf3c Mon Sep 17 00:00:00 2001 From: Tilman Kranz Date: Mon, 29 Nov 2021 05:50:47 +0100 Subject: [PATCH] consolidate format_commit_stats --- linuxfoo-gitlab.php | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/linuxfoo-gitlab.php b/linuxfoo-gitlab.php index 85b603c..fb31146 100644 --- a/linuxfoo-gitlab.php +++ b/linuxfoo-gitlab.php @@ -48,40 +48,28 @@ class LinuxfooGitlab { } static function format_commit($atts, $commit) { - $out = ''; - preg_match('/^....-..-../', $commit->committed_date, $m); $date = $m[0]; $title = htmlspecialchars($commit->title, ENT_NOQUOTES|ENT_HTML5|ENT_SUBSTITUTE, 'UTF-8', FALSE); - $out .= + return $date.' '. __('by', 'linuxfoo-gitlab').' '.$commit->author_name. ': '. ''.$commit->short_id.' '.$title; - - return $out; } static function format_commit_stats($atts, $commits_count, $branch) { - $out = ''; - - if($commits_count==0) { - $out .= - __('No commits', 'linuxfoo-gitlab'). - (is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"'). - (is_null($atts['since']) ? '' : ' '.('since '.$atts['since'].' ago')).'.'; - } - else { - $out .= - /* translators: %d: maximum number of commits displayed */ - sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count). - (is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"'). - (is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':'; - } - - return $out; + return + ( + ($commits_count==0) + ? __('No commits', 'linuxfoo-gitlab') + /* translators: %d: maximum number of commits displayed */ + : sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count) + ). + (is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"'). + (is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':'; } static function commits_list($atts, $project_url) {