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

Commit

Permalink
allow multiple branches in githubparser
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Nov 13, 2009
1 parent 22e89f0 commit 5603650
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 13 additions & 8 deletions modules/local/githubparser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ sub fetch_feed {
my $pkg = shift;
my $self = $objects_by_package{$pkg};
my $atom = XML::Atom::Client->new();
my $feed = $atom->getFeed($$self{url});
$pkg->process_feed($feed);
for (@{$self->{urls}}) {
my $feed = $atom->getFeed($_);
$pkg->process_feed($feed);
}
}


Expand Down Expand Up @@ -112,7 +114,7 @@ sub longest_common_prefix {

=head2 try_link
modules::local::githubparser->try_link($url, ['network', '#channel'], $branch);
modules::local::githubparser->try_link($url, ['network', '#channel'], $branches);
This is called by autofeed.pm. Given a github.com URL, try to determine the
project name and canonical path. Then configure a feed reader for it if one
Expand All @@ -122,7 +124,8 @@ The array reference containing network and channel are optional. If not
specified, magnet/#parrot is assumed. If the feed already exists but didn't
have the specified target, the existing feed is extended.
C<$branch> is optional, and defaults to C<master>.
C<$branches> is an optional array reference containing the branches to be
monitored, and defaults to C<[qw(master)]>.
Currently supports 3 URL formats:
Expand All @@ -136,9 +139,9 @@ links on the Languages page at time of writing.
=cut

sub try_link {
my ($pkg, $url, $target, $branch) = @_;
my ($pkg, $url, $target, $branches) = @_;
$target = ['magnet', '#parrot'] unless defined $target;
$branch = 'master' unless defined $branch;
$branches = ['master'] unless defined $branches;
my($author, $project);
if($url =~ m|http://(?:wiki.)?github.com/([^/]+)/([^/]+)/?|) {
$author = $1;
Expand Down Expand Up @@ -169,9 +172,11 @@ sub try_link {

# create new feed
# url, feed_name, targets, objects_by_package
my $rss_link = "http://github.com/feeds/$author/commits/$project/$branch";
my @rss_links =
map "http://github.com/feeds/$author/commits/$project/$_",
@$branches;
my $self = {
url => $rss_link,
urls => \@@rss_links,
feed_name => $project,
modulename => $modulename,
targets => [ $target ],
Expand Down
6 changes: 5 additions & 1 deletion modules/local/rakudolog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ config and simply add the freenode channel to the list of targets.)
my $url = 'http://github.com/rakudo/rakudo';

sub init {
modules::local::githubparser->try_link($url, ['freenode', '#perl6']);
modules::local::githubparser->try_link(
$url,
['freenode', '#perl6'],
['master', 'ng'],
);
}

1;

0 comments on commit 5603650

Please sign in to comment.