This commit is contained in:
Bob E Moe
2019-06-25 09:15:51 +01:00
parent 4290eab80a
commit 5bac8a9772
7 changed files with 143 additions and 56 deletions

27
no_milestone.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
//Adds a no-milestone label to any issues with no milestone
//Also removes the label if present on an issue with a milestone
include("src/Client.php");
include("src/Issue.php");
include("src/Label.php");
include("src/Repo.php");
$config=include("config.php");
$client=new Client($config['url'],$config['user'],$config['pass']);
$repo=$client->getRepo('james','test');
$nolabelLabel=$repo->getLabelByName('no-label');
if(!$nolabelLabel) die ("Can't find 'no-label' label in repo\n");
$nomilestoneLabel=$repo->getLabelByName('no-milestone');
if(!$nomilestoneLabel) die ("Can't find 'no-milestone' label in repo\n");
$callback=function($issue) use ($nomilestoneLabel){
if( count($issue->getData()->milestone)==0 && !$issue->hasLabel($nomilestoneLabel) ){
$issue->addLabel( $nomilestoneLabel );
}elseif( count($issue->getData()->milestone)>0 && $issue->hasLabel($nomilestoneLabel) ){
$issue->removeLabel( $nomilestoneLabel );
}
};
$repo->forIssues($callback);