convert to using forIssues
This commit is contained in:
parent
5002e79e29
commit
d420b12bf8
@ -11,17 +11,18 @@
|
|||||||
// we will then have $client and $repo available
|
// we will then have $client and $repo available
|
||||||
require('setup.php');
|
require('setup.php');
|
||||||
|
|
||||||
//callback function to process the issues
|
// loop through all matching issues
|
||||||
$tmp=function($issue) use ($repo){
|
// we use getIssues() here rather than forIssues() (see https://git.jhodges.co.uk/jhodges/GiteaBot/issues/1)
|
||||||
|
foreach($repo->getIssues(['q'=>'delete me']) as $issue){
|
||||||
|
// check for exact match
|
||||||
if($issue->title=='delete me'){
|
if($issue->title=='delete me'){
|
||||||
|
// remove all labels
|
||||||
foreach($issue->labels as $label){
|
foreach($issue->labels as $label){
|
||||||
$issue->removeLabel($label);
|
$issue->removeLabel($label);
|
||||||
}
|
}
|
||||||
|
//change status and title.
|
||||||
$issue->state='closed';
|
$issue->state='closed';
|
||||||
$issue->title='deleted';
|
$issue->title='deleted';
|
||||||
$issue->save();
|
$issue->save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//do the search and process the results
|
|
||||||
$repo->forIssues($tmp,['q'=>'delete me']);
|
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
#!/bin/php
|
#!/bin/php
|
||||||
<?php
|
<?php
|
||||||
/*****************************************************
|
/**************************************************************
|
||||||
* This will process all issues that match "NAG!":
|
* This will delete all comments that match a specific keyword
|
||||||
* 1. Delete any comments that body exactly match "NAG!"
|
* 1. Process all issues that match "NAG!":
|
||||||
******************************************************/
|
* 2. Delete any comments that body exactly match "NAG!"
|
||||||
|
**************************************************************/
|
||||||
|
|
||||||
// load the config, create the connection and load the repo sepcified on the cmd line args
|
// load the config, create the connection and load the repo sepcified on the cmd line args
|
||||||
// we will then have $client and $repo available
|
// we will then have $client and $repo available
|
||||||
require('setup.php');
|
require('setup.php');
|
||||||
|
|
||||||
//callback function to process the issues
|
// loop through the issues
|
||||||
$tmp=function($issue) use ($repo){
|
// we use getIssues() here rather than forIssues() (see https://git.jhodges.co.uk/jhodges/GiteaBot/issues/1)
|
||||||
|
foreach($repo->getIssues(['q'=>'NAG!']) as $issue){
|
||||||
|
// loop through the current issues comments
|
||||||
foreach($issue->getComments() as $comment){
|
foreach($issue->getComments() as $comment){
|
||||||
|
// if the comment body matches
|
||||||
if($comment->body=='NAG!'){
|
if($comment->body=='NAG!'){
|
||||||
|
// delete the commend
|
||||||
$repo->deleteComment($comment);
|
$repo->deleteComment($comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
//do the search and process the results
|
|
||||||
$repo->forIssues($tmp,['q'=>'NAG!']);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user