diff options
Diffstat (limited to 'WebKitTools/Scripts/commit-log-editor')
| -rwxr-xr-x | WebKitTools/Scripts/commit-log-editor | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/WebKitTools/Scripts/commit-log-editor b/WebKitTools/Scripts/commit-log-editor index 75017e3..1be0fd0 100755 --- a/WebKitTools/Scripts/commit-log-editor +++ b/WebKitTools/Scripts/commit-log-editor @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +# Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ use webkitdirs; sub normalizeLineEndings($$); sub removeLongestCommonPrefixEndingInDoubleNewline(\%); +sub isCommitLogEditor($); sub usage { @@ -61,30 +62,47 @@ if (!$log) { my $baseDir = baseProductDir(); my $editor = $ENV{SVN_LOG_EDITOR}; -if (!$editor) { - $editor = $ENV{CVS_LOG_EDITOR}; -} +$editor = $ENV{CVS_LOG_EDITOR} if !$editor; +$editor = "" if isCommitLogEditor($editor); + +my $splitEditor = 1; if (!$editor) { my $builtEditorApplication = "$baseDir/Release/Commit Log Editor.app/Contents/MacOS/Commit Log Editor"; - $editor = $builtEditorApplication if -x $builtEditorApplication; + if (-x $builtEditorApplication) { + $editor = $builtEditorApplication; + $splitEditor = 0; + } } if (!$editor) { my $builtEditorApplication = "$baseDir/Debug/Commit Log Editor.app/Contents/MacOS/Commit Log Editor"; - $editor = $builtEditorApplication if -x $builtEditorApplication; + if (-x $builtEditorApplication) { + $editor = $builtEditorApplication; + $splitEditor = 0; + } } if (!$editor) { - my $installedEditorApplication = "$ENV{HOME}/Applications/Commit Log Editor.app/Contents/MacOS/Commit Log Editor"; - $editor = $installedEditorApplication if -x $installedEditorApplication; + my $builtEditorApplication = "$ENV{HOME}/Applications/Commit Log Editor.app/Contents/MacOS/Commit Log Editor"; + if (-x $builtEditorApplication) { + $editor = $builtEditorApplication; + $splitEditor = 0; + } } -if (!$editor) { - $editor = $ENV{EDITOR} || "/usr/bin/vi"; + +$editor = $ENV{EDITOR} if !$editor; +$editor = "/usr/bin/vi" if !$editor; + +my @editor; +if ($splitEditor) { + @editor = split ' ', $editor; +} else { + @editor = ($editor); } my $inChangesToBeCommitted = !isGit(); my @changeLogs = (); my $logContents = ""; my $existingLog = 0; -open LOG, $log or die; +open LOG, $log or die "Could not open the log file."; while (<LOG>) { if (isGit()) { if (/^# Changes to be committed:$/) { @@ -102,7 +120,7 @@ while (<LOG>) { } $existingLog = isGit() && !(/^#/ || /^\s*$/) unless $existingLog; - push @changeLogs, makeFilePathRelative($1) if $inChangesToBeCommitted && (/^M....(.*ChangeLog)\r?\n?$/ || /^#\tmodified: (.*ChangeLog)/) && !/-ChangeLog/; + push @changeLogs, makeFilePathRelative($1) if $inChangesToBeCommitted && (/^(?:M|A)....(.*ChangeLog)\r?\n?$/ || /^#\t(?:modified|new file): (.*ChangeLog)$/) && !/-ChangeLog$/; } close LOG; @@ -120,9 +138,8 @@ if ($regenerateLog && $existingLog && scalar(@changeLogs) > 0) { $keepExistingLog = 0 if ($key eq "r"); } -# Don't change anything if there's already a log message -# (as can happen with git-commit --amend) -exec $editor, @ARGV if $existingLog && $keepExistingLog; +# Don't change anything if there's already a log message (as can happen with git-commit --amend). +exec (@editor, @ARGV) if $existingLog && $keepExistingLog; my $topLevel = determineVCSRoot(); @@ -151,8 +168,8 @@ for my $changeLog (@changeLogs) { # Remove indentation spaces $line =~ s/^ {8}//; - # Save the reviewed by line - if ($line =~ m/^Reviewed by .*/) { + # Save the reviewed / rubber stamped by line. + if ($line =~ m/^Reviewed by .*/ || $line =~ m/^Rubber[ \-]?stamped by .*/) { $reviewedByLine = $line; next; } @@ -184,7 +201,6 @@ for my $changeLog (@changeLogs) { $reviewedByLine = ""; } - $lineCount++; $contents .= $line; } else { @@ -204,12 +220,6 @@ for my $changeLog (@changeLogs) { my $sortKey = lc $label; if ($label eq "top level") { $sortKey = ""; - } elsif ($label eq "Tools") { - $sortKey = "-, just after top level"; - } elsif ($label eq "WebBrowser") { - $sortKey = lc "WebKit, WebBrowser after"; - } elsif ($label eq "WebCore") { - $sortKey = lc "WebFoundation, WebCore after"; } elsif ($label eq "LayoutTests") { $sortKey = lc "~, LayoutTests last"; } @@ -251,7 +261,7 @@ if (isGit() && scalar keys %changeLogSort == 0) { print NEWLOG $logContents; close NEWLOG; -system $editor, "$log.edit"; +system (@editor, "$log.edit"); open NEWLOG, "$log.edit" or exit; my $foundComment = 0; @@ -307,3 +317,9 @@ sub removeLongestCommonPrefixEndingInDoubleNewline(\%) } return substr($prefix, 0, $lastDoubleNewline + 2); } + +sub isCommitLogEditor($) +{ + my $editor = shift; + return $editor =~ m/commit-log-editor/; +} |
