Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Looks fine now
  • Loading branch information
JJ committed Feb 8, 2019
2 parents 9c251b6 + 15e2211 commit 68cf586
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
28 changes: 17 additions & 11 deletions bin/update-issues.p6
Expand Up @@ -12,7 +12,7 @@ unit sub MAIN(


my %modules = from-json slurp $blin-data;
my @issues = get-issues $token;
my @issues = get-issues :$token;
my $template-text = slurp $template;

for @issues -> $issue {
Expand All @@ -25,21 +25,27 @@ for %modules.keys.sort -> $name {
if $module<status> eq OK {
if $ticket and $ticket<state> ne closed {
note Closing issue {$ticket<number>} for $name;
# close-single-issue $ticket<url>, $token
# close-single-issue $ticket<url>, :$token
}
} else {
if not $ticket or $ticket<state> eq closed {
note Creating new issue for $name;

my $text = $template-text;
$text .= subst: 「MODULE」, 42;
$text .= subst: 「MODULE-URL」, 42; # https://modules.perl6.org/dist/$module
$text .= subst: 「OUTPUT」, 42;
$text .= subst: 「PING-AUTHOR」, 42;
$text .= subst: 「PREVIOUS-TICKET」, 42;
$text .= subst: 「PREVIOUS-TICKET」, 42;
$text .= subst: 「BLIN-MESSAGE」, 42;
# submit-issue $token, $text
my $title = $name;
my @labels;
my $body = $template-text;
my $ping-author = False ?? Ping @AlexDaniel. !! ;
my $previous-ticket = $ticket ?? Preivous ticket: # ~ $ticket<number> !! ;

$body .= subst: 「MODULE」, $name;
$body .= subst: 「MODULE-URL」, https://modules.perl6.org/dist/$module;
$body .= subst: 「BLIN-MESSAGE」, $module<status>;
$body .= subst: 「OUTPUT」, $module<output>;
$body .= subst: 「PING-AUTHOR」, $ping-author;
$body .= subst: 「PREVIOUS-TICKET」, $previous-ticket;

# submit-issue(:$token, :$title, :$body, :@labels);

}
}
}
21 changes: 12 additions & 9 deletions lib/Unbitrot/Utils.pm6
Expand Up @@ -6,8 +6,8 @@ use Cro::HTTP::Client;

constant \url = https://api.github.com/repos/perl6/ecosystem-unbitrot/issues?per_page=60&direction=asc&state=all;

#| gets the issues from the repo
sub get-issues($token) is export {
#| Returns all issues from the repo
sub get-issues(:$token, :$url = url) is export {
my @issues;
my $cur-url = url;
loop {
Expand All @@ -29,21 +29,24 @@ sub get-issues($token) is export {
@issues;
}

#| Edit issue
#| Close/Open an issue
sub close-single-issue($url, $token, :$state = 'closed') is export {
patch( :$url, :$token, body => { :$state } ),
}

#| patch with cro
sub patch(:$url, :$token, :$body ) {
#| Submit a new issue
sub submit-issue(:$token, :$title, :$body, :@labels, :$url = url) {
my %body = %(:$title, :$body, :@labels,);

my $resp = await Cro::HTTP::Client.patch: $url,
use Cro::HTTP::Client;
my $resp = await Cro::HTTP::Client.post: $url,
headers => [
User-Agent => perl6 ecosystem unbitrot,
Authorization => token $token,
],
],
content-type => application/json,
body => $body,
body => %body,
;
return await $resp.body;

return (await $resp.body)<number> # issue number
}

0 comments on commit 68cf586

Please sign in to comment.