28 lines
981 B
PHP
28 lines
981 B
PHP
<?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);
|