-
-
Save rivy/e7e69dba8ae1d8ee494f504822561bae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Copyright 2015 by David Golden | |
# Licensed under CC0 https://creativecommons.org/publicdomain/zero/1.0/ | |
# Updated 2016-03-01: | |
# - more variation in organzations selected; you will want to customize this yourself | |
# - splits out wishlists differently/correctly | |
# - reports only PRs unless --all is specified | |
use v5.10; | |
use strict; | |
use warnings; | |
use utf8; | |
use Carp; | |
use Net::GitHub; | |
use Getopt::Lucid ':all'; | |
use List::Util qw/max/; | |
my $opts = Getopt::Lucid->getopt( | |
[ | |
#<<< No perltidy | |
Switch('all|a'), | |
Switch('ptg'), | |
#>>> | |
] | |
); | |
$opts->validate; | |
sub _git_config { | |
my $key = shift; | |
chomp( my $value = `git config --get $key` ); | |
croak "Unknown $key" unless $value; | |
return $value; | |
} | |
my %WATCHLIST = map { $_ => 1 } qw( | |
CPAN-Common-Index | |
File-Temp | |
Parse-CPAN-Meta | |
Perl-OSType | |
Sub-Uplevel | |
YAML-Tiny | |
); | |
sub _ptg_watched { | |
my $repo = $_[0]{repository}{name}; | |
return 1 if $WATCHLIST{$repo}; | |
return 1 if $repo =~ /^CPAN-Meta/; | |
return; | |
} | |
my $github_user = _git_config("github.user"); | |
my $github_token = _git_config("github.token"); | |
my $gh = Net::GitHub->new( access_token => $github_token ); | |
my @issues; | |
# just xdg issues | |
push @issues, $gh->query("/user/issues?filter=all&state=open"); | |
while ( $gh->has_next_page ) { | |
push @issues, $gh->next_page; | |
} | |
# select org issues | |
for my $org ( qw/dagolden cpan-testers/ ) { | |
push @issues, $gh->query("/orgs/$org/issues?filter=all&state=open"); | |
while ( $gh->has_next_page ) { | |
push @issues, $gh->next_page; | |
} | |
} | |
# select PTG issues | |
if ( $opts->get_ptg ) { | |
push @issues, grep { _ptg_watched($_) } $gh->query("/orgs/Perl-Toolchain-Gang/issues?filter=all&state=open"); | |
while ( $gh->has_next_page ) { | |
push @issues, grep { _ptg_watched($_) } $gh->next_page; | |
} | |
} | |
my %dash; | |
for my $i (@issues) { | |
my $name = $i->{repository}{name}; | |
for (qw/PR wish issue total/) { | |
$dash{ $name }{$_} //= 0; | |
} | |
my $labels = $i->{labels}; | |
my $wishlist = $i->{title} =~ /wish-?list/i | |
|| grep { /enhancement|question|wishlist/i } map { $_->{name} } @{ $i->{labels} }; | |
my $type = | |
exists $i->{pull_request} ? 'PR' | |
: $wishlist ? 'wish' | |
: 'issue'; | |
$dash{ $name }{$type}++; | |
$dash{ $name }{total}++ unless $wishlist; | |
} | |
my $width = max( map { length($_) } keys %dash ); | |
my @sorted = sort { | |
$dash{$b}{PR} <=> $dash{$a}{PR} | |
|| $dash{$b}{issue} <=> $dash{$a}{issue} | |
|| lc($a) cmp lc($b) | |
} keys %dash; | |
for my $k (@sorted) { | |
next unless $opts->get_all || $dash{$k}{PR}; | |
printf( "%*s %3d %3d %3d\n", | |
$width, $k, $dash{$k}{PR}, $dash{$k}{issue}, $dash{$k}{wish}, ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment