Skip to content

Instantly share code, notes, and snippets.

@moznion
Created September 3, 2012 15:08
Show Gist options
  • Save moznion/3609964 to your computer and use it in GitHub Desktop.
Save moznion/3609964 to your computer and use it in GitHub Desktop.
Get number of pull-request
#!/usr/bin/perl
use strict;
use warnings;
use 5.012;
use WebService::Simple;
my $target_username = "USER_NAME"; # <= input your self
my $target_reponame = "REPOSITORY_NAME"; # <= input your self
my $query = "pulls";
my $github = WebService::Simple->new(
base_url => 'https://api.github.com/',
response_parser => 'JSON'
);
my $number_of_pull_requests = 0;
my $pull_requests = $github->get( "repos/$target_username/$target_reponame/$query" );
my $parsed_pull_requests = $pull_requests->parse_response;
foreach my $list (@{ $parsed_pull_requests }) {
foreach my $key (keys %{ $list }) {
if ($key ~~ /number/) {
$number_of_pull_requests++;
}
}
}
say $number_of_pull_requests;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment