[debug]\n"); } $debug = ($argc==4 && $argv[3]=='debug'); //open connection and repo $client=new Client($config['url'],$config['user'],$config['pass'],$debug); $repo=$client->getRepo($argv[1],$argv[2]); //get the labels of interest $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"); //define the function to process each issue $callback=function($issue) use ($nolabelLabel,$nomilestoneLabel){ // do the no-label thing $labelCount=count($issue->labels); if($issue->hasLabel($nolabelLabel)) $labelCount--; //dont count the no-label label if($nomilestoneLabel && $issue->hasLabel($nomilestoneLabel)) $labelCount--; //dont count the no-milestone label if($labelCount==0 && !$issue->hasLabel($nolabelLabel) ){ $issue->addLabel( $nolabelLabel ); }elseif( $labelCount>0 && $issue->hasLabel($nolabelLabel) ){ $issue->removeLabel( $nolabelLabel ); } //do the no-milestone thing if( !$issue->milestone && !$issue->hasLabel($nomilestoneLabel) ){ $issue->addLabel( $nomilestoneLabel ); }elseif( $issue->milestone && $issue->hasLabel($nomilestoneLabel) ){ $issue->removeLabel( $nomilestoneLabel ); } }; //loop through issues and call the callback $repo->forIssues($callback);