mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
Show "No difference." when code is the same in cc diff
This commit is contained in:
parent
cb74a9be1e
commit
4adedc2a90
@ -13,8 +13,8 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 424,
|
BUILD_REVISION => 425,
|
||||||
BUILD_DATE => "2013-08-23",
|
BUILD_DATE => "2013-08-24",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -186,11 +186,15 @@ if($code =~ m/^\s*diff\s*$/i) {
|
|||||||
} else {
|
} else {
|
||||||
use Text::WordDiff;
|
use Text::WordDiff;
|
||||||
my $diff = word_diff \$last_code[1], \$last_code[0], { STYLE => 'MARKUP' };
|
my $diff = word_diff \$last_code[1], \$last_code[0], { STYLE => 'MARKUP' };
|
||||||
|
if($diff !~ /(?:<del>|<ins>)/) {
|
||||||
|
$diff = "No difference.";
|
||||||
|
} else {
|
||||||
$diff =~ s/<del>([^\s]+)(\s+)<\/del>/<del>$1<\/del>$2/g;
|
$diff =~ s/<del>([^\s]+)(\s+)<\/del>/<del>$1<\/del>$2/g;
|
||||||
$diff =~ s/<ins>([^\s]+)(\s+)<\/ins>/<ins>$1<\/ins>$2/g;
|
$diff =~ s/<ins>([^\s]+)(\s+)<\/ins>/<ins>$1<\/ins>$2/g;
|
||||||
$diff =~ s/<del>((?:(?!<del>).)*)<\/del>\s*<ins>((?:(?!<ins>).)*)<\/ins>/<replaced `$1` with `$2`>/g;
|
$diff =~ s/<del>((?:(?!<del>).)*)<\/del>\s*<ins>((?:(?!<ins>).)*)<\/ins>/<[replaced `$1` with `$2`]>/g;
|
||||||
$diff =~ s/<del>(.*?)<\/del>/<removed `$1`>/g;
|
$diff =~ s/<del>(.*?)<\/del>/<[removed `$1`]>/g;
|
||||||
$diff =~ s/<ins>(.*?)<\/ins>/<inserted `$1`>/g;
|
$diff =~ s/<ins>(.*?)<\/ins>/<[inserted `$1`]>/g;
|
||||||
|
}
|
||||||
|
|
||||||
print "$nick: $diff\n";
|
print "$nick: $diff\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user