From: Kevin Cernekee <cernekee@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH/RFC 3/3] gitweb: change highlighting of "atnight" commits
Date: Sat, 19 Mar 2011 13:48:27 -0700 [thread overview]
Message-ID: <e420df635f1146388df59a27bdc6e68b@localhost> (raw)
In-Reply-To: <4f21902cf5f72b30a96465cf911d13aa@localhost>
The current behavior is to show the timestamp for "atnight" commits
(commits for which the local time is between 00:00 and 05:59,
inclusive) in red, on the commit and commitdiff views. On the
log view, the timestamps are shown normally.
Swap this behavior so that the commit and commitdiff views do
not color these timestamps red, but the log view does. This allows
late-night commits to be easily identified (and possibly subjected to
extra scrutiny) when reading through the change log.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
Personally, I am not too concerned with the "atnight" behavior because
only a minuscule percentage of our commits happen late at night. But
since we're touching this code, we might as well tweak anything in there
that needs tweaking.
gitweb/gitweb.perl | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index aa038bd..2d4349f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3946,17 +3946,17 @@ sub git_print_section {
}
# Returns a timestamp string, which may contain HTML.
-# If $commit_view is 0, the string looks like:
+# If -commit_view is not specified, the string looks like:
# Fri, 18 Mar 2011 01:28:57 +0000 [localtime disabled]
# Thu, 17 Mar 2011 18:28:57 -0700 [localtime enabled]
-# If $commit_view is 1, the string looks like:
+# If -commit_view is specified, the string looks like:
# Fri, 18 Mar 2011 01:28:57 +0000 (18:28 -0700) [localtime disabled]
# Thu, 17 Mar 2011 18:28:57 -0700 (01:28 +0000) [localtime enabled]
-# If $commit_view is 1, the entire string will use the "atnight" class
+# If -atnight is specified, the entire string will use the "atnight" class
# (red text) if the local time is between 00:00 and 05:59 inclusive.
# This helps to flag commits made in the wee hours of the morning.
sub timestamp_html {
- my ($date, $commit_view) = @_;
+ my ($date, %opts) = @_;
my $timestamp;
my $alt_time;
@@ -3973,13 +3973,13 @@ sub timestamp_html {
$date->{'minute_local'},
$date->{'tz_local'});
}
- if ($commit_view) {
+ if ($opts{-commit_view}) {
$timestamp .= $alt_time;
- if ($date->{'hour_local'} < 6) {
- $timestamp = "<span class=\"atnight\">" .
- $timestamp .
- "</span>";
- }
+ }
+ if ($opts{-atnight} && $date->{'hour_local'} < 6) {
+ $timestamp = "<span class=\"atnight\">" .
+ $timestamp .
+ "</span>";
}
return $timestamp;
}
@@ -3994,7 +3994,7 @@ sub git_print_authorship {
my %ad = format_date($co->{'author_epoch'}, $co->{'author_tz'});
print "<$tag class=\"author_date\">" .
format_search_author($author, "author", esc_html($author)) .
- " [" . timestamp_html(\%ad, 0) . "] ".
+ " [" . timestamp_html(\%ad, -atnight => 1) . "] ".
git_get_avatar($co->{'author_email'}, -pad_before => 1) .
"</$tag>\n";
}
@@ -4021,7 +4021,7 @@ sub git_print_authorship_rows {
"</td></tr>\n" .
"<tr>" .
"<td></td><td> " .
- timestamp_html(\%wd, 1) .
+ timestamp_html(\%wd, -commit_view => 1) .
"</td>" .
"</tr>\n";
}
@@ -5434,7 +5434,7 @@ sub git_summary {
"<tr id=\"metadata_owner\"><td>owner</td><td>" . esc_html($owner) . "</td></tr>\n";
if (keys %cd) {
print "<tr id=\"metadata_lchange\"><td>last change</td><td>" .
- timestamp_html(\%cd, 0) . "</td></tr>\n";
+ timestamp_html(\%cd) . "</td></tr>\n";
}
# use per project git URL list in $projectroot/$project/cloneurl
--
1.7.4.1
next prev parent reply other threads:[~2011-03-19 20:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-19 20:48 [PATCH v2 1/3] gitweb: rename parse_date() to format_date() Kevin Cernekee
2011-03-19 20:48 ` [PATCH v5 2/3] gitweb: introduce localtime feature Kevin Cernekee
2011-03-19 20:48 ` Kevin Cernekee [this message]
2011-03-19 22:18 ` [PATCH -1/3] gitweb: Always call parse_date with timezone parameter Jakub Narebski
2011-03-19 22:53 ` [PATCH -1/3 (amend)] " Jakub Narebski
2011-03-19 22:56 ` [PATCH -1/3] " Kevin Cernekee
2011-03-20 0:25 ` Jakub Narebski
2011-03-20 0:27 ` Junio C Hamano
2011-03-20 2:11 ` [PATCH v2 4/3] gitweb: Always call format_date " Kevin Cernekee
2011-03-20 10:37 ` Jakub Narebski
2011-03-20 11:07 ` Jakub Narebski
2011-03-20 20:47 ` Kevin Cernekee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e420df635f1146388df59a27bdc6e68b@localhost \
--to=cernekee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).