| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | my %topics=( |
| 4 | git => [qw(linus git linux rebase rebased merge merged cherry-pick |
| 5 | branch branched branches git-* push pull pushed pulled)], |
| 6 | ubuntu => [qw(Mark MOTU PPA ubuntu debian rock rocks rule dapper |
| 7 | feisty fiesty gutsy hoary hardy edgy |
| 8 | universe launchpad gnome desktop naked sabdfl community)], |
| 9 | debian => [qw(Debian rules rule ian murdock upstream release |
| 10 | stable unstable testing apt apt-get deb developer NM RM |
| 11 | NMU FTBFS BTS ITP DFSG non-free free d.o)], |
| 12 | ); |
| 13 | |
| 14 | if (! @ARGV) { |
| 15 | @ARGV=@{$topics{git}}; |
| 16 | } |
| 17 | elsif (@ARGV == 1 && exists $topics{lc $ARGV[0]}) { |
| 18 | @ARGV=@{$topics{lc $ARGV[0]}}; |
| 19 | } |
| 20 | |
| 21 | my $total_awesomeness_dude=join("|", |
| 22 | map { |
| 23 | $_=quotemeta($_); |
| 24 | s/\\\*/.*/g; |
| 25 | s/\\\?/./g; |
| 26 | qr/\b$_\b/; |
| 27 | } reverse sort @ARGV); |
| 28 | |
| 29 | my $len=0; |
| 30 | my $indent=""; |
| 31 | my $indent_printed=0; |
| 32 | while (<STDIN>) { |
| 33 | if (/$total_awesomeness_dude/i) { |
| 34 | if (/^([>|][>|\s]*)/) { |
| 35 | if ($indent ne $1) { |
| 36 | print "\n" if $len; |
| 37 | $len=0; |
| 38 | $indent=$1; |
| 39 | $indent_printed=0; |
| 40 | } |
| 41 | } |
| 42 | else { |
| 43 | if (length $indent && $indent_printed) { |
| 44 | print "\n"; |
| 45 | $len=0; |
| 46 | } |
| 47 | $indent=""; |
| 48 | $indent_printed=0; |
| 49 | } |
| 50 | |
| 51 | while(/(($total_awesomeness_dude)[.?!]*)/ig) { |
| 52 | $len+=length($1)+1; |
| 53 | if ($len > 70) { |
| 54 | print "\n"; |
| 55 | $len=0; |
| 56 | } |
| 57 | if (length $indent && ! $indent_printed) { |
| 58 | print $indent; |
| 59 | $indent_printed=1; |
| 60 | } |
| 61 | print $1." "; |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | print "\n" if $len; |