Commit 2856c637 authored by abarth@webkit.org's avatar abarth@webkit.org

2009-06-16 Adam Barth <abarth@webkit.org>

        Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=26437

        Make the commit-log-editor match the ambient line endings in commit
        messages.

        * Scripts/commit-log-editor:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44727 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1d1a836a
2009-06-16 Adam Barth <abarth@webkit.org>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=26437
Make the commit-log-editor match the ambient line endings in commit
messages.
* Scripts/commit-log-editor:
2009-06-16 Xan Lopez <xlopez@igalia.com>
Reviewed by Gustavo Noronha.
......
......@@ -36,6 +36,8 @@ use lib $FindBin::Bin;
use VCSUtils;
use webkitdirs;
sub normalizeLineEndings($$);
my $log = $ARGV[0];
my $baseDir = baseProductDir();
......@@ -81,6 +83,13 @@ while (<LOG>) {
}
close LOG;
# We want to match the line endings of the existing log file in case they're
# different from perl's line endings.
my $endl = "\n";
if ($logContents =~ /(\r?\n)/g) {
$endl = $1;
}
# Don't change anything if there's already a log message
# (as can happen with git-commit --amend)
exec $editor, @ARGV if $existingLog;
......@@ -134,11 +143,11 @@ open NEWLOG, ">$log.edit" or die;
for my $sortKey (sort keys %changeLogSort) {
my $label = $changeLogSort{$sortKey};
if (keys %changeLogSort > 1) {
print NEWLOG "\n" if !$first;
print NEWLOG normalizeLineEndings("\n", $endl) if !$first;
$first = 0;
print NEWLOG "$label:\n\n";
print NEWLOG normalizeLineEndings("$label:\n\n", $endl);
}
print NEWLOG $changeLogContents{$label};
print NEWLOG normalizeLineEndings($changeLogContents{$label}, $endl);
}
print NEWLOG $logContents;
close NEWLOG;
......@@ -187,3 +196,10 @@ sub topLevelSourceDirectory
return File::Spec->rel2abs(File::Spec->catdir(map { ".." } File::Spec->splitdir($path)));
}
}
sub normalizeLineEndings($$)
{
my ($string, $endl) = @_;
$string =~ s/\r?\n/$endl/g;
return $string;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment