Changeset 23748 in webkit


Ignore:
Timestamp:
Jun 23, 2007 1:49:16 AM (17 years ago)
Author:
hausmann
Message:

Added support for populating ChangeLog entries from given git commits
using --git-commit=<commitish> and --git-reviewer=<name>.

Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r23740 r23748  
     12007-06-22  Simon Hausmann  <hausmann@kde.org>
     2
     3        Reviewed by Adam Roben.
     4
     5        Added support for populating ChangeLog entries from given git commits
     6        using --git-commit=<commitish> and --git-reviewer=<name>.
     7
     8        * Scripts/prepare-ChangeLog:
     9
    1102007-06-22  Timothy Hatcher  <timothy@apple.com>
    211
  • trunk/WebKitTools/Scripts/prepare-ChangeLog

    r21850 r23748  
    8080sub isSVN();
    8181
     82my $gitCommit = 0;
     83my $gitReviewer = "";
    8284my $openChangeLogs = 0;
    8385my $showHelp = 0;
     86my $spewDiff = $ENV{"PREPARE_CHANGELOG_DIFF"};
    8487my $updateChangeLogs = 1;
    85 my $spewDiff = $ENV{"PREPARE_CHANGELOG_DIFF"};
    8688my $parseOptionsResult =
    8789    GetOptions("diff|d!" => \$spewDiff,
     90               "git-commit:s" => \$gitCommit,
     91               "git-reviewer:s" => \$gitReviewer,
    8892               "help|h!" => \$showHelp,
    8993               "open|o!" => \$openChangeLogs,
    9094               "update!" => \$updateChangeLogs);
    9195if (!$parseOptionsResult || $showHelp) {
    92     print STDERR basename($0) . " [-d|--diff] [-h|--help] [-o|--open] [svndir1 [svndir2 ...]]\n";
     96    print STDERR basename($0) . " [-d|--diff] [-h|--help] [-o|--open] [--git-commit=<committish>] [--git-reviewer=<name>] [svndir1 [svndir2 ...]]\n";
    9397    print STDERR "  -d|--diff      Spew diff to stdout when running\n";
     98    print STDERR "  --git-commit   Populate the ChangeLogs from the specified git commit\n";
     99    print STDERR "  --git-reviewer When populating the ChangeLogs from a git commit claim that the spcified name reviewed the change.\n";
     100    print STDERR "                 This option is useful when the git commit lacks a Signed-Off-By: line\n";
    94101    print STDERR "  -h|--help      Show this help message\n";
    95102    print STDERR "  -o|--open      Open ChangeLogs in an editor when done\n";
     
    210217  || "set EMAIL_ADDRESS environment variable";
    211218
     219if ($gitCommit) {
     220    $name = `$GIT log --max-count=1 --pretty=\"format:%an\" \"$gitCommit\"`;
     221    $email_address = `$GIT log --max-count=1 --pretty=\"format:%ae\" \"$gitCommit\"`;
     222}
     223
    212224# Remove trailing parenthesized notes from user name (bit of hack).
    213225$name =~ s/\(.*?\)\s*$//g;
     
    258270    open CHANGE_LOG, "> ${prefix}ChangeLog" or die "Could not write ${prefix}ChangeLog\n.";
    259271    print CHANGE_LOG "$date  $name  <$email_address>\n\n";
    260     print CHANGE_LOG "        Reviewed by NOBODY (OO" . "PS!).\n\n";
    261     if ($prefix =~ m/WebCore/ || `pwd` =~ m/WebCore/) {
    262         print CHANGE_LOG "        WARNING: NO TEST CASES ADDED OR CHANGED\n\n" unless $changedLayoutTests;
     272
     273    if ($gitCommit) {
     274        my $gitLog = `$GIT cat-file commit \"$gitCommit\"`;
     275        my @lines = split(/\n/, $gitLog);
     276
     277        my $reviewer = "";
     278
     279        $gitLog = "";
     280        my $inHeader = 1;
     281        foreach my $line (@lines) {
     282            if ($inHeader) {
     283                if (!$line) {
     284                    $inHeader = 0;
     285                }
     286                next;
     287            }
     288            if ($line =~ /[Ss]igned-[Oo]ff-[Bb]y: (.+)/) {
     289                if (!$reviewer) {
     290                    $reviewer = $1;
     291                } else {
     292                    $reviewer .= ", " . $1;
     293                }
     294            } elsif (length $line == 0) {
     295                $gitLog = $gitLog . "\n";
     296            } else {
     297                $gitLog = $gitLog . "        " . $line . "\n";
     298            }
     299        }
     300
     301        if (!$reviewer) {
     302            $reviewer = $gitReviewer;
     303        }
     304
     305        if (!$reviewer) {
     306            print "WARNING!!! Change was not reviewed!\n";
     307            $reviewer = "NOBODY (OO" . "PS!)";
     308        }
     309
     310        print CHANGE_LOG "        Reviewed by $reviewer.\n\n";
     311        print CHANGE_LOG $gitLog . "\n";
     312    } else {
     313        print CHANGE_LOG "        Reviewed by NOBODY (OO" . "PS!).\n\n";
     314        if ($prefix =~ m/WebCore/ || `pwd` =~ m/WebCore/) {
     315            print CHANGE_LOG "        WARNING: NO TEST CASES ADDED OR CHANGED\n\n" unless $changedLayoutTests;
     316        }
    263317    }
    264318
     
    872926        $prefix = "$SVN diff --diff-cmd diff -x -N";
    873927    } elsif (isGit()) {
    874         $prefix = "$GIT diff HEAD --";
     928        if ($gitCommit) {
     929            return "$GIT diff \"$gitCommit^\" \"$gitCommit\"";
     930        } else {
     931            $prefix = "$GIT diff HEAD --";
     932        }
    875933    }
    876934
     
    889947        # FIXME: This command will give status for the whole repository, not
    890948        # just the files passed in.
    891         $command = "$GIT status";
     949        if ($gitCommit) {
     950            $command = "$GIT diff -r --name-status -M \"$gitCommit^\" \"$gitCommit\"";
     951        } else {
     952            $command = "$GIT status";
     953        }
    892954    }
    893955
     
    9531015            }
    9541016        } elsif (isGit()) {
    955             if (/^# Changes to be committed:$/ || /^# Changed but not updated:$/) {
    956                 $inGitCommitSection = 1;
    957                 next;
    958             }
    959             last if $inGitCommitSection && /^# \S/;
    960 
    961             if ($inGitCommitSection && /^#\s+([^:]+):\s+((.+) -> )?(.+)$/) {
    962                 $status = $1;
    963                 $original = $3;
    964                 $file = $4;
     1017            if ($gitCommit) {
     1018                if (/^([ADM])\t(.+)$/) {
     1019                    $status = $1;
     1020                    $file = $2;
     1021                } elsif (/^(R)[0-9]{1,3}\t([^\t]+)\t([^\t\n]+)$/) { # for example: R90%    newfile    oldfile
     1022                    $status = $1;
     1023                    $file = $2;
     1024                    $original = $3;
     1025                } else {
     1026                    print;  # error output from git diff
     1027                }
     1028            } else {
     1029                if (/^# Changes to be committed:$/ || /^# Changed but not updated:$/) {
     1030                    $inGitCommitSection = 1;
     1031                    next;
     1032                }
     1033                last if $inGitCommitSection && /^# \S/;
     1034
     1035                if ($inGitCommitSection && /^#\s+([^:]+):\s+((.+) -> )?(.+)$/) {
     1036                    $status = $1;
     1037                    $original = $3;
     1038                    $file = $4;
     1039                }
    9651040            }
    9661041        }
     
    10001075    );
    10011076
    1002     return $svn{$status} if isSVN();
     1077    # deliberately share the same description between svn status output and git diff --name-status
     1078    return $svn{$status} if (isSVN() || $gitCommit);
    10031079    return $git{$status} if isGit();
    10041080}
     
    10171093
    10181094    return $svn{$status} if isSVN();
     1095    return 0 if $gitCommit; # an existing commit cannot have conflicts
    10191096    return $git{$status} if isGit();
    10201097}
     
    10381115    );
    10391116
    1040     return sprintf($svn{$status}, $original) if isSVN() && exists $svn{$status};
     1117    # deliberately share the same description between svn status output and git diff --name-status
     1118    return sprintf($svn{$status}, $original) if (isSVN() || $gitCommit) && exists $svn{$status};
    10411119    return sprintf($git{$status}, $original) if isGit() && exists $git{$status};
    10421120    return undef;
Note: See TracChangeset for help on using the changeset viewer.