git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC 3/3] gitweb: change highlighting of "atnight" commits

From
Kevin Cernekee <cernekee@gmail.com>
Date
Mar 19, 2011, 20:48 UTC
Message-ID
<e420df635f1146388df59a27bdc6e68b@localhost>
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
Previous: Kevin CernekeeNext: Jakub Narebski
Message 3 of 12 in “gitweb: rename parse_date() to format_date()”
  1. 1/3 gitweb: rename parse_date() to format_date()Kevin Cernekee, Mar 19, 2011
  2. 2/3 gitweb: introduce localtime featureKevin Cernekee, Mar 19, 2011
  3. 3/3 gitweb: change highlighting of "atnight" commitsKevin Cernekee, Mar 19, 2011
  4. 1/3 gitweb: Always call parse_date with timezone parameterJakub Narebski, Mar 19, 2011
  5. 1/3 gitweb: Always call parse_date with timezone parameterJakub Narebski, Mar 19, 2011
  6. Kevin CernekeeMar 19, 2011
  7. Jakub NarebskiMar 20, 2011
  8. Junio C HamanoMar 20, 2011
  9. 4/3 gitweb: Always call format_date with timezone parameterKevin Cernekee, Mar 20, 2011
  10. Jakub NarebskiMar 20, 2011
  11. Jakub NarebskiMar 20, 2011
  12. Kevin CernekeeMar 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.