Script to switch off the "issues" feature for all my Perl repos. (Issues for my Perl repos should be reported to rt.cpan.org.)
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 | |
use Z; | |
my $app = app sub { | |
class 'Visitor' => sub { | |
constant 'USER' => 'tobyink'; # Your username! | |
constant 'TOKEN' => 'XXXXXXX'; # https://github.com/settings/tokens | |
has 'code' => ( type => CodeRef, required => true ); | |
has 'repos' => ( is => 'lazy', init_arg => undef ); | |
has 'github' => ( type => Object, is => 'lazy' ); | |
method '_build_github' => sub { | |
my ( $self ) = ( shift ); | |
require Pithub; | |
return 'Pithub'->new( | |
'token' => $self->TOKEN, | |
'user' => $self->USER, | |
); | |
}; | |
method '_build_repos' => sub { | |
my ( $self ) = ( shift ); | |
my $r = $self->github->repos->list( 'user' => $self->USER ); | |
$r->auto_pagination( true ); | |
return $r; | |
}; | |
method 'run' => sub { | |
my ( $self ) = ( shift ); | |
while ( my $row = $self->repos->next ) { | |
$self->code->( $self, $row ); | |
} | |
}; | |
}; | |
}; | |
$app->new_visitor( | |
'code' => sub { | |
my ( $visitor, $repo ) = @_; | |
return unless $repo->{'name'} =~ /^p5-/; | |
return unless $repo->{'owner'}{'login'} eq $visitor->USER; | |
if ( $repo->{has_issues} ) { | |
say "Disabling issues for ", $repo->{html_url}; | |
$visitor->github->repos->update( | |
'user' => $visitor->USER, | |
'repo' => $repo->{name}, | |
'data' => { 'has_issues' => \0 }, | |
); | |
} | |
}, | |
)->run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note line 41. My convention is to name Perl project repos with names matching
/^p5-/
.