mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 01:49:11 +00:00
Use Text::Wrap instead of perl's built-in format function.
This still breaks log filename incorrectly but is a step in the right direction.
This commit is contained in:
parent
c2f3f60583
commit
3911e4f7bf
@ -20,6 +20,7 @@
|
||||
# The goal is to emulate "hg log --style=changelog" via perl format.
|
||||
|
||||
use Getopt::Std;
|
||||
use Text::Wrap;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
@ -45,6 +46,9 @@ my $key_date = "";
|
||||
my $log_size = 0;
|
||||
my @lines;
|
||||
|
||||
# Wrap like "hg log --style=changelog"
|
||||
$Text::Wrap::columns = 77;
|
||||
|
||||
while (<LOG>) {
|
||||
chomp;
|
||||
if (/^log size (\d+)$/) {
|
||||
@ -76,14 +80,17 @@ while (<LOG>) {
|
||||
$hash = shift(@lines);
|
||||
|
||||
# Commit message body (multi-line)
|
||||
my $sep = "";
|
||||
foreach (@lines) {
|
||||
last if $_ eq "--HG--";
|
||||
if (defined($body)) {
|
||||
$_ = "\r" if $_ eq "";
|
||||
$body .= " $_";
|
||||
} else {
|
||||
$body = $_;
|
||||
if ($_ eq "") {
|
||||
$sep = "\n\n";
|
||||
next;
|
||||
}
|
||||
s/^\s+//;
|
||||
s/\s+$//;
|
||||
$body .= ${sep} . $_;
|
||||
$sep = " ";
|
||||
}
|
||||
} else {
|
||||
# Not a log entry, must be the file list
|
||||
@ -98,20 +105,11 @@ exit(0);
|
||||
|
||||
sub print_entry
|
||||
{
|
||||
my $hash = '[' . shift . ']';
|
||||
my $hash = shift;
|
||||
my $body = shift;
|
||||
my $files = "* " . join(", ", @_) . ":";
|
||||
|
||||
local $= = 9999; # to silence warning (hack)
|
||||
|
||||
format =
|
||||
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
||||
$files
|
||||
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
||||
$body
|
||||
@*
|
||||
$hash
|
||||
|
||||
.
|
||||
write;
|
||||
print wrap("\t", "\t", $files) . "\n";
|
||||
print wrap("\t", "\t", $body) . "\n";
|
||||
print "\t[$hash]\n\n";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user