Print this page
4389 webrev should fetch preparer info from git if available


   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  25 #
  26 
  27 # Copyright 2008, 2010, Richard Lowe
  28 # Copyright 2012 Marcel Telka <marcel@telka.sk>

  29 
  30 #
  31 # This script takes a file list and a workspace and builds a set of html files
  32 # suitable for doing a code review of source changes via a web page.
  33 # Documentation is available via the manual page, webrev.1, or just
  34 # type 'webrev -h'.
  35 #
  36 # Acknowledgements to contributors to webrev are listed in the webrev(1)
  37 # man page.
  38 #
  39 
  40 REMOVED_COLOR=brown
  41 CHANGED_COLOR=blue
  42 NEW_COLOR=blue
  43 
  44 HTML='<?xml version="1.0"?>
  45 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  46     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  47 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
  48 


3463 exec 3<&1                        # duplicate stdout to FD3.
3464 exec 1<&-                        # Close stdout.
3465 exec > $INDEXFILE            # Open stdout to index file.
3466 
3467 print "$HTML<head>$STDHEAD"
3468 print "<title>$WNAME</title>"
3469 print "</head>"
3470 print "<body id=\"SUNWwebrev\">"
3471 print "<div class=\"summary\">"
3472 print "<h2>Code Review for $WNAME</h2>"
3473 
3474 print "<table>"
3475 
3476 #
3477 # Get the preparer's name:
3478 #
3479 # If the SCM detected is Mercurial, and the configuration property
3480 # ui.username is available, use that, but be careful to properly escape
3481 # angle brackets (HTML syntax characters) in the email address.
3482 #


3483 # Otherwise, use the current userid in the form "John Doe (jdoe)", but
3484 # to maintain compatibility with passwd(4), we must support '&' substitutions.
3485 #
3486 preparer=
3487 if [[ "$SCM_MODE" == mercurial ]]; then
3488         preparer=`hg showconfig ui.username 2>/dev/null`
3489         if [[ -n "$preparer" ]]; then
3490                 preparer="$(echo "$preparer" | html_quote)"



3491         fi
3492 fi



3493 if [[ -z "$preparer" ]]; then
3494         preparer=$(
3495             $PERL -e '
3496                 ($login, $pw, $uid, $gid, $quota, $cmt, $gcos) = getpwuid($<);
3497                 if ($login) {
3498                     $gcos =~ s/\&/ucfirst($login)/e;
3499                     printf "%s (%s)\n", $gcos, $login;
3500                 } else {
3501                     printf "(unknown)\n";
3502                 }
3503         ')
3504 fi
3505 
3506 PREPDATE=$(LC_ALL=C /usr/bin/date +%Y-%b-%d\ %R\ %z\ %Z)
3507 print "<tr><th>Prepared by:</th><td>$preparer on $PREPDATE</td></tr>"
3508 print "<tr><th>Workspace:</th><td>${PRETTY_CWS:-$CWS}"
3509 print "</td></tr>"
3510 print "<tr><th>Compare against:</th><td>"
3511 if [[ -n $parent_webrev ]]; then
3512         print "webrev at $parent_webrev"




   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  25 #
  26 
  27 # Copyright 2008, 2010, Richard Lowe
  28 # Copyright 2012 Marcel Telka <marcel@telka.sk>
  29 # Copyright 2013 Ivan Richwalski <ivan@seppuku.net>
  30 
  31 #
  32 # This script takes a file list and a workspace and builds a set of html files
  33 # suitable for doing a code review of source changes via a web page.
  34 # Documentation is available via the manual page, webrev.1, or just
  35 # type 'webrev -h'.
  36 #
  37 # Acknowledgements to contributors to webrev are listed in the webrev(1)
  38 # man page.
  39 #
  40 
  41 REMOVED_COLOR=brown
  42 CHANGED_COLOR=blue
  43 NEW_COLOR=blue
  44 
  45 HTML='<?xml version="1.0"?>
  46 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  47     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  48 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n'
  49 


3464 exec 3<&1                        # duplicate stdout to FD3.
3465 exec 1<&-                        # Close stdout.
3466 exec > $INDEXFILE            # Open stdout to index file.
3467 
3468 print "$HTML<head>$STDHEAD"
3469 print "<title>$WNAME</title>"
3470 print "</head>"
3471 print "<body id=\"SUNWwebrev\">"
3472 print "<div class=\"summary\">"
3473 print "<h2>Code Review for $WNAME</h2>"
3474 
3475 print "<table>"
3476 
3477 #
3478 # Get the preparer's name:
3479 #
3480 # If the SCM detected is Mercurial, and the configuration property
3481 # ui.username is available, use that, but be careful to properly escape
3482 # angle brackets (HTML syntax characters) in the email address.
3483 #
3484 # For git, use the user.name and user.email properties if they are set.
3485 #
3486 # Otherwise, use the current userid in the form "John Doe (jdoe)", but
3487 # to maintain compatibility with passwd(4), we must support '&' substitutions.
3488 #
3489 preparer=
3490 if [[ "$SCM_MODE" == mercurial ]]; then
3491         preparer=`hg showconfig ui.username 2>/dev/null`
3492 elif [[ "$SCM_MODE" == git ]]; then
3493         preparer=$( git config user.name 2>/dev/null )
3494         prepmail=$( git config user.email 2>/dev/null )
3495         if [[ -n "$prepmail" ]]; then
3496                 preparer="$preparer <$prepmail>"
3497         fi
3498 fi
3499 if [[ -n "$preparer" ]]; then
3500         preparer="$(echo "$preparer" | html_quote)"
3501 fi
3502 if [[ -z "$preparer" ]]; then
3503         preparer=$(
3504             $PERL -e '
3505                 ($login, $pw, $uid, $gid, $quota, $cmt, $gcos) = getpwuid($<);
3506                 if ($login) {
3507                     $gcos =~ s/\&/ucfirst($login)/e;
3508                     printf "%s (%s)\n", $gcos, $login;
3509                 } else {
3510                     printf "(unknown)\n";
3511                 }
3512         ')
3513 fi
3514 
3515 PREPDATE=$(LC_ALL=C /usr/bin/date +%Y-%b-%d\ %R\ %z\ %Z)
3516 print "<tr><th>Prepared by:</th><td>$preparer on $PREPDATE</td></tr>"
3517 print "<tr><th>Workspace:</th><td>${PRETTY_CWS:-$CWS}"
3518 print "</td></tr>"
3519 print "<tr><th>Compare against:</th><td>"
3520 if [[ -n $parent_webrev ]]; then
3521         print "webrev at $parent_webrev"