Skip to content

Instantly share code, notes, and snippets.

@schwern
Created March 10, 2011 14:21
Show Gist options
  • Select an option

  • Save schwern/864149 to your computer and use it in GitHub Desktop.

Select an option

Save schwern/864149 to your computer and use it in GitHub Desktop.
Get the number of issues from a github project
use Net::GitHub::V2::Issues;
use URI;
# Examples:
# http://github.com/schwern/test-more/tree/master
# http://github.com/sukria/Dancer
sub num_github_issues {
my $url = URI->new(shift);
return unless $url->host =~ m{\.?github.com$};
my $path = $url->path;
my($owner, $repo) = grep { length $_ } split m{/}, $path;
return unless $owner && $repo;
my $issues = Net::GitHub::V2::Issues->new(
owner => $owner, repo => $repo
);
return unless $issues;
my $open_issues = $issues->list("open");
return unless ref $open_issues eq 'ARRAY';
return scalar @$open_issues;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment