lintian: r845 - in trunk: debian doc frontend lib man
Author: rra
Date: 2007-04-11 06:05:08 +0200 (Wed, 11 Apr 2007)
New Revision: 845
Modified:
trunk/debian/changelog
trunk/doc/README
trunk/frontend/lintian
trunk/frontend/lintian-info
trunk/lib/Tags.pm
trunk/man/lintian.1
Log:
Fix the color output to work the way sketched out in the bug discussion.
Add support to lintian-info to ignore ANSI color escapes when parsing
lintian tags. Don't ever use bold for tags, and colorize only the tag,
not the rest of the lintian output.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2007-04-11 03:35:40 UTC (rev 844)
+++ trunk/debian/changelog 2007-04-11 04:05:08 UTC (rev 845)
@@ -104,7 +104,7 @@
"L. Redrejo" Rodríguez. (Closes: #403515)
* doc/README:
- + Document --no-colored-output option. Patch from Loïc Minier.
+ + Document --color option. Based on a patch from Loïc Minier.
* depcheck/deppages.pl:
+ [JA] Perl syntax corrections.
@@ -113,11 +113,13 @@
* frontend/lintian:
+ [JA] Removed trailing spaces and other perl syntax corrections.
- + [JA] Add --no-colored-output option to disable ANSI color output, even
- when STDOUT is a TTY. Patch from Loïc Minier.
+ + [RA] Add --color option to optionally colorize lintian tags based on
+ their severity. Based on a patch from Loïc Minier.
+ [RA] Accept emergency as a valid urgency and check urgencies
case-insensitively since that's what Policy specifies. Thanks, Joey
Hess. (Closes: #412577)
+ * frontend/lintian-info:
+ + [RA] Ignore ANSI color sequences when parsing lintian tags.
* lib/Checker.pm
+ [JA] Perl syntax corrections.
@@ -125,16 +127,16 @@
+ [JA] Perl syntax corrections.
* lib/Tags.pm
+ [JA] Perl syntax corrections.
- + [JA] Support for ANSI color output.
- Patch from Loïc Minier. (Closes #399714).
+ + [RA] Support for colorizing lintian tags based on their severity.
+ Based on a patch from Loïc Minier. (Closes: #399714)
* man/lintian.1:
- + [JA] Document --no-colored-output. Patch from Loïc Minier.
+ + [RA] Document --color. Based on a patch from Loïc Minier.
* unpack/unpack-*pkg*
+ [JA] Perl syntax corrections.
- -- Russ Allbery <rra@debian.org> Thu, 15 Mar 2007 16:24:02 -0700
+ -- Russ Allbery <rra@debian.org> Tue, 10 Apr 2007 21:02:11 -0700
lintian (1.23.28) unstable; urgency=high
Modified: trunk/doc/README
===================================================================
--- trunk/doc/README 2007-04-11 03:35:40 UTC (rev 844)
+++ trunk/doc/README 2007-04-11 04:05:08 UTC (rev 845)
@@ -73,7 +73,7 @@
-l X, --unpack-level X set default unpack level to X
-o, --no-override ignore overrides
--show-overrides output tags that have been overriden
- --no-colored-output disable color output (default is enabled on TTY)
+ --color never/always/auto disable, enable, or enable color for TTY
-U X, --unpack-info X specify which info should be collected
-m, --md5sums check md5sums when processing a .changes file
--allow-root suppress lintian's warning when run as root
Modified: trunk/frontend/lintian
===================================================================
--- trunk/frontend/lintian 2007-04-11 03:35:40 UTC (rev 844)
+++ trunk/frontend/lintian 2007-04-11 04:05:08 UTC (rev 845)
@@ -52,7 +52,7 @@
my $unpack_level = undef; #flag for -l|--unpack-level switch
our $no_override = 0; #flag for -o|--no-override switch
our $show_overrides = 0; #flag for --show-overrides switch
-our $no_colored_output = 0; #flag for --no-colored-output switch
+our $color = 'never'; #flag for --color switch
my $check_md5sums = 0; #flag for -m|--md5sums switch
my $allow_root = 0; #flag for --allow-root swtich
my $fail_on_warnings = 0; #flag for --fail-on-warnings switch
@@ -144,7 +144,7 @@
-l X, --unpack-level X set default unpack level to X
-o, --no-override ignore overrides
--show-overrides output tags that have been overriden
- --no-colored-output disable ANSI color output (default enabled)
+ --color never/always/auto disable, enable, or enable color for TTY
-U X, --unpack-info X specify which info should be collected
-m, --md5sums check md5sums when processing a .changes file
--allow-root suppress lintian\'s warning when run as root
@@ -261,7 +261,7 @@
"unpack-level|l=i" => \$unpack_level,
"no-override|o" => \$no_override,
"show-overrides" => \$show_overrides,
- "no-colored-output" => \$no_colored_output,
+ "color=s" => \$color,
"unpack-info|U=s" => \&record_unpack_info,
"md5sums|m" => \$check_md5sums,
"allow-root" => \$allow_root,
@@ -921,7 +921,7 @@
$Tags::show_info = $display_infotags;
$Tags::show_overrides = $show_overrides;
-$Tags::no_colored_output = $no_colored_output;
+$Tags::color = $color;
use warnings;
# load information about checker scripts
Modified: trunk/frontend/lintian-info
===================================================================
--- trunk/frontend/lintian-info 2007-04-11 03:35:40 UTC (rev 844)
+++ trunk/frontend/lintian-info 2007-04-11 04:05:08 UTC (rev 845)
@@ -67,10 +67,12 @@
}
# Otherwise, read input files or STDIN, watch for tags, and add descriptions
-# whenever we see one, can, and haven't already explained that tag.
+# whenever we see one, can, and haven't already explained that tag. Strip off
+# color sequences.
while (<>) {
print;
chomp;
+ s/\e[[\d;]*m//g;
my $tag;
my ($type, $pkg, @pieces) = split(/:\s+/);
Modified: trunk/lib/Tags.pm
===================================================================
--- trunk/lib/Tags.pm 2007-04-11 03:35:40 UTC (rev 844)
+++ trunk/lib/Tags.pm 2007-04-11 04:05:08 UTC (rev 845)
@@ -45,7 +45,7 @@
our $max_severity = 99;
our $min_significance = 1;
our $max_significance = 99;
-our $no_colored_output = 0;
+our $color = 'never';
# The master hash with all tag info. Key is the tag name, value another hash
# with the following keys:
@@ -83,7 +83,7 @@
my @sig_to_qualifier = ( '??', '?', '', '!' );
my @sev_to_code = qw( I W W E E );
-my @sev_to_color = ( 'bold', 'yellow', 'yellow bold', 'red', 'red bold' );
+my @sev_to_color = ( 'cyan', 'yellow', 'yellow', 'red', 'red' );
# Add a new tag, supplied as a hash reference
sub add_tag {
@@ -270,18 +270,18 @@
$extra = " @$information" if @$information;
$extra = '' if $extra eq ' ';
my $code = $codes{$tag_info->{type}};
- # code -> severity -> color
my $severity = $type_to_sev{$tag_info->{type}};
- my $color = $sev_to_color[$severity];
- $color = '' if $no_colored_output;
- # disable color output is STDOUT isn't a TTY
- $color = '' if ! -t STDOUT;
$code = 'O' if $tag_info->{overridden}{override};
my $type = '';
$type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
- my $output = "$code: $pkg_info->{pkg}$type: $tag_info->{tag}$extra\n";
- $output = colored($output, $color) if $color;
+ my $output = "$code: $pkg_info->{pkg}$type: ";
+ if ($color eq 'always' || ($color eq 'auto' && -t STDOUT)) {
+ $output .= colored($tag_info->{tag}, $sev_to_color[$severity]);
+ } else {
+ $output .= $tag_info->{tag};
+ }
+ $output .= "$extra\n";
print $output;
}
@@ -294,17 +294,18 @@
$extra = '' if $extra eq ' ';
my $code = $sev_to_code[$tag_info->{severity}];
$code = 'O' if $tag_info->{overridden}{override};
- my $color = $sev_to_color[$tag_info->{severity}];
- $color = '' if $no_colored_output;
- # disable color output is STDOUT isn't a TTY
- $color = '' if ! -t STDOUT;
my $qualifier = $sig_to_qualifier[$tag_info->{significance}];
$qualifier = '' if $code eq 'O';
my $type = '';
$type = " $pkg_info->{type}" if $pkg_info->{type} ne 'binary';
- my $output = "$code$qualifier: $pkg_info->{pkg}$type: $tag_info->{tag}$extra\n";
- $output = colored($output, $color) if $color;
+ my $output = "$code$qualifier: $pkg_info->{pkg}$type: ";
+ if ($color eq 'always' || ($color eq 'auto' && -t STDOUT)) {
+ $output .= colored($tag_info->{tag}, $sev_to_color[$tag_info->{severity}]);
+ } else {
+ $output .= $tag_info->{tag};
+ }
+ $output .= "$extra\n";
print $output;
Modified: trunk/man/lintian.1
===================================================================
--- trunk/man/lintian.1 2007-04-11 03:35:40 UTC (rev 844)
+++ trunk/man/lintian.1 2007-04-11 04:05:08 UTC (rev 845)
@@ -157,8 +157,11 @@
Output tags that have been overriden.
.TP
-.BR \-\-no\-colored\-output
-Disable ANSI color output, even when stdout is a TTY.
+.BR \-\-color (never|always|auto)
+Whether to colorize tags in lintian output based on their severity. The
+default is "never", which never uses color. "always" will always use
+color, while "auto" will use color only if the output is going to a
+terminal.
.TP
.BR \-U " info1,info2,..., " \-\-unpack\-info " info1,info2,..."
Reply to: