Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
[parsers] gitoriousparser.pm: make all tests pass by supporting multi…
Browse files Browse the repository at this point in the history
…ple commits per Atom feed entry
  • Loading branch information
Geoffrey Broadwell committed Oct 11, 2009
1 parent b3bd304 commit 38a525c
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions modules/local/gitoriousparser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ sub process_feed {

# skip the first run, to prevent new installs from flooding the channel
foreach my $item (@items) {
my ($rev) = ($item->content->body =~ m|/commit/([a-z0-9]{40})|);
if(exists($$self{not_first_time})) {
# output new entries to channel
next if exists($$self{seen}{$rev});
$$self{seen}{$rev} = 1;
$self->output_item($item, $rev);
} else {
$$self{seen}{$rev} = 1;
my @revs = $item->content->body =~ m|/commit/([a-z0-9]{40})|g;
for my $rev (reverse @revs) {
$self->output_item($item, $rev)
if !$$self{seen}{$rev}++ && $$self{not_first_time};
}
}
$$self{not_first_time} = 1;
Expand Down Expand Up @@ -165,25 +161,41 @@ sub output_item {
$desc = '(no commit message)';
}

my @lines = split("\n", $desc);
my $message = decode_entities($lines[-1]);
($link = $message) =~m|<a href=".{77}">[a-fA-F0-9]{7}</a>:|;
$message =~ s|</?ul>|| ;
$message =~ s|</?li>|| ;
@lines = split( /<a href.{80}>[a-fA-F0-9]{7}<\/a>:/, $message);
$rev = substr($rev, 0, 7);

$self->emit_karma_message(
feed => $$self{feed_name},
rev => $rev,
user => $creator,
log => \@lines,
link => $link,
prefix => "",
targets => $$self{targets},
);

main::lprint($$self{feed_name}.": output_item: output rev $rev");
$desc = decode_entities($desc);
$desc =~ s,(<ul>),$1\n,g;
$desc =~ s,(</li>),$1\n,g;

my @lines = split "\n", $desc;
for my $line (@lines) {
my ($item) = $line =~ m,\s*<li>(.*)</li>$,;
next unless $item;

my ($name, $link, $message)
= $item =~ m,^([^<]+)<a href="([^"]+)">[[:xdigit:]]{7}</a>:\s*([^<]+)$,;
next unless $link;

my ($commit) = $link =~ m,/commit/([[:xdigit:]]{40}),;
next unless $commit && $commit eq $rev;

$link = "http://gitorious.org$link"
unless $link =~ m,^https?://,;

# warn "line: $line, name: $name, link: $link, message: $message, commit: $commit\n";

$commit = substr($commit, 0, 7);

$self->emit_karma_message(
feed => $$self{feed_name},
rev => $commit,
user => $creator,
log => [$message],
link => $link,
prefix => "",
targets => $$self{targets},
);

main::lprint($$self{feed_name}.": output_item: output rev $commit");
}
}


Expand Down

0 comments on commit 38a525c

Please sign in to comment.