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