r43810 - in /scripts/KGB: debian/changelog server/KGB server/kgb.conf.sample
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Mon Sep 7 11:27:07 UTC 2009
Author: dmn
Date: Mon Sep 7 11:27:01 2009
New Revision: 43810
URL: http://svn.debian.org/wsvn/?sc=1&rev=43810
Log:
server: make colors configurable
supports 16 colors and bold, underline and inverse attributes
thanks $DIETY, no one has invented 'blink' yet
Modified:
scripts/KGB/debian/changelog
scripts/KGB/server/KGB
scripts/KGB/server/kgb.conf.sample
Modified: scripts/KGB/debian/changelog
URL: http://svn.debian.org/wsvn/scripts/KGB/debian/changelog?rev=43810&op=diff
==============================================================================
--- scripts/KGB/debian/changelog (original)
+++ scripts/KGB/debian/changelog Mon Sep 7 11:27:01 2009
@@ -3,6 +3,7 @@
[ Damyan Ivanov ]
* server
+ use "dir" or "dirs" depending on the number (1 or greater)
+ + make colors configurable
* client
+ avoid wrong trimming of changed paths when branch or module cannot be
detected
Modified: scripts/KGB/server/KGB
URL: http://svn.debian.org/wsvn/scripts/KGB/server/KGB?rev=43810&op=diff
==============================================================================
--- scripts/KGB/server/KGB (original)
+++ scripts/KGB/server/KGB Mon Sep 7 11:27:01 2009
@@ -205,6 +205,14 @@
0..$#{$conf->{channels}});
$conf->{chanidx} = \%chanidx;
+ $conf->{colors} ||= {};
+ $conf->{colors}{repository} ||= 'bold';
+ $conf->{colors}{revision} ||= 'bold';
+ $conf->{colors}{path} ||= 'teal';
+ $conf->{colors}{author} ||= 'green';
+ $conf->{colors}{branch} ||= 'red';
+ $conf->{colors}{module} ||= 'purple';
+
return $conf;
}
sub load_conf($) {
@@ -329,6 +337,41 @@
use Digest::SHA1 qw(sha1_hex);
use File::Basename;
+our %color_codes = (
+ bold => "\002", # ^B
+ underline => "\037", # ^_
+ reverse => "\026", # ^V
+ black => "\00301",
+ navy => "\00302",
+ green => "\00303",
+ red => "\00304",
+ brown => "\00305",
+ purple => "\00306",
+ orange => "\00307",
+ yellow => "\00308",
+ lime => "\00309",
+ teal => "\00310",
+ aqua => "\00311",
+ blue => "\00312",
+ fuchsia => "\00313",
+ silver => "\00314",
+ white => "\00316",
+);
+
+sub colorize {
+ my( $style, $text ) = @_;
+
+ my $color = $KGB::config->{colors}{$style};
+
+ return $text unless $color;
+
+ for ( split( /\s+/, $color ) ) {
+ $text = $color_codes{$_} . $text if $color_codes{$_};
+ }
+
+ $text .= "\017";
+}
+
sub do_commit_msg {
my($kernel, $response, $repo_id, $rev, $paths, $log, $author, $branch,
$module ) = @_;
@@ -383,16 +426,18 @@
{
$path_string = join(' ', @$paths);
}
- $path_string = "\00310$path_string\017";
-
- my $repo_head = "\002$repo_id\017:";
- my $author_string = "\00303$author\017";
- $author_string .= " \00305$branch\017" if defined($branch);
- my @string = "$repo_head $author_string * r\002$rev\017 $log[0]";
+ $path_string = colorize( path=>$path_string );
+
+ my $repo_head = colorize( repository=>$repo_id );
+ my $author_string = colorize( author=>$author );
+ $author_string .= " " . colorize( branch=>$branch ) if defined($branch);
+ my @string = "$repo_head $author_string * r"
+ . colorize( revision=>$rev ) . " $log[0]";
foreach(1..$#log) {
push @string, "$repo_head $log[$_]";
}
- $path_string = "\00306$module\017 $path_string" if defined($module);
+ $path_string = colorize( module=>$module ) . " $path_string"
+ if defined($module);
push @string, "$repo_head $path_string";
my @tmp;
# Standard says 512 (minus \r\n), anyway that's further trimmed when
@@ -404,7 +449,8 @@
while($_ = shift @string) {
if(length($_) > $MAGIC_MAX_LINE) {
push @tmp, substr($_, 0, $MAGIC_MAX_LINE);
- unshift @string, "\002$repo_id\017: " . substr($_, $MAGIC_MAX_LINE);
+ unshift @string, colorize( repository=>$repo_id ) . ": "
+ . substr($_, $MAGIC_MAX_LINE);
} else {
push @tmp, $_;
}
Modified: scripts/KGB/server/kgb.conf.sample
URL: http://svn.debian.org/wsvn/scripts/KGB/server/kgb.conf.sample?rev=43810&op=diff
==============================================================================
--- scripts/KGB/server/kgb.conf.sample (original)
+++ scripts/KGB/server/kgb.conf.sample Mon Sep 7 11:27:01 2009
@@ -38,3 +38,15 @@
pid_dir: /var/run/kgb-bot
# anything less is rejected
min_protocol_ver: 1
+# default colors:
+# colors:
+# repository: bold
+# revision: bold
+# author: green
+# branch: red
+# module: purple
+# path: teal
+# you can combine them like "bold red" (ouch!)
+# available colors: black, navy, green, red, brown, purple, orange, yellow,
+# lime, teal, aqua, blue, fuchsia, gray, silver, white
+# availablel modifiers: bold underline reverse
More information about the Pkg-perl-cvs-commits
mailing list