diff --git a/src/close_all.php b/src/close_all.php
index 9f22e76..10cafb6 100755
--- a/src/close_all.php
+++ b/src/close_all.php
@@ -1,16 +1,17 @@
#!/usr/bin/php
getIssues() as $issue){
- $issue->state='closed';
- $issue->save();
+foreach ($repo->getIssues() as $issue) {
+ $issue->state = 'closed';
+ $issue->save();
}
diff --git a/src/delete_labels.php b/src/delete_labels.php
index 3939b7e..091d50e 100755
--- a/src/delete_labels.php
+++ b/src/delete_labels.php
@@ -1,27 +1,27 @@
#!/usr/bin/php
getLabelByName($name);
- if($label){ //it exists
- //delete it
- $repo->deleteLabel($label);
+ $label = $repo->getLabelByName($name);
+ if ($label) { //it exists
+ //delete it
+ $repo->deleteLabel($label);
}
}
diff --git a/src/delete_me.php b/src/delete_me.php
index 38d6495..5cd66b7 100755
--- a/src/delete_me.php
+++ b/src/delete_me.php
@@ -1,28 +1,28 @@
#!/usr/bin/php
getIssues(['q'=>'delete me']) as $issue){
- // check for exact match
- if($issue->title=='delete me'){
- // remove all labels
- foreach($issue->labels as $label){
- $issue->removeLabel($label);
+foreach ($repo->getIssues(['q' => 'delete me']) as $issue) {
+ // check for exact match
+ if ('delete me' == $issue->title) {
+ // remove all labels
+ foreach ($issue->labels as $label) {
+ $issue->removeLabel($label);
+ }
+ //change status and title.
+ $issue->state = 'closed';
+ $issue->title = 'deleted';
+ $issue->save();
}
- //change status and title.
- $issue->state='closed';
- $issue->title='deleted';
- $issue->save();
- }
-};
+}
diff --git a/src/delete_nags.php b/src/delete_nags.php
index 0f15da6..3e07018 100755
--- a/src/delete_nags.php
+++ b/src/delete_nags.php
@@ -1,24 +1,24 @@
#!/usr/bin/php
getIssues(['q'=>'NAG!']) as $issue){
- // loop through the current issues comments
- foreach($issue->getComments() as $comment){
- // if the comment body matches
- if($comment->body=='NAG!'){
- // delete the commend
- $repo->deleteComment($comment);
+foreach ($repo->getIssues(['q' => 'NAG!']) as $issue) {
+ // loop through the current issues comments
+ foreach ($issue->getComments() as $comment) {
+ // if the comment body matches
+ if ('NAG!' == $comment->body) {
+ // delete the commend
+ $repo->deleteComment($comment);
+ }
}
- }
}
diff --git a/src/edit.php b/src/edit.php
index 67b802c..1c9b448 100755
--- a/src/edit.php
+++ b/src/edit.php
@@ -1,30 +1,30 @@
#!/usr/bin/php
number."\n".$issue->title."\ntexting\n".time()."\n```\n";
+$text = function ($issue) {
+ return "\n```plain\n".$issue->number."\n".$issue->title."\ntexting\n".time()."\n```\n";
};
//callback function to add/replace the tag with our text
-$tmp=function($issue) use ($text){
- // add a tag to the body if to doesn't exist
- if( strpos($issue->body,'')===false ){
- $issue->body.='
';
- }
- //replace the tag contents with the result from our $text function
- $issue->body=preg_replace("#.*?#s",''.$text($issue).'',$issue->body);
- $issue->save();
+$tmp = function ($issue) use ($text) {
+ // add a tag to the body if to doesn't exist
+ if (false === strpos($issue->body, '')) {
+ $issue->body .= '
';
+ }
+ //replace the tag contents with the result from our $text function
+ $issue->body = preg_replace('#.*?#s', ''.$text($issue).'', $issue->body);
+ $issue->save();
};
//process ALL issues
diff --git a/src/no_label_milestone.php b/src/no_label_milestone.php
index dc451d1..f4300e2 100755
--- a/src/no_label_milestone.php
+++ b/src/no_label_milestone.php
@@ -1,40 +1,50 @@
#!/usr/bin/php
getLabelByName('no-label');
-if(!$nolabelLabel) die ("Can't find 'no-label' label in repo\n");
+$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");
+$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 );
- }
+$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 (0 == $labelCount && !$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 all issues and call the callback
diff --git a/src/setup.php b/src/setup.php
index bd77de3..f5fbf4c 100644
--- a/src/setup.php
+++ b/src/setup.php
@@ -1,17 +1,17 @@
[debug]\n");
}
-$debug = ($argc==4 && $argv[3]=='debug');
+$debug = (4 == $argc && 'debug' == $argv[3]);
//open connection and repo
-$client=new Client($config['url'],$config['user'],$config['pass'],$debug);
-$repo=$client->getRepo($argv[1],$argv[2]);
-
+$client = new Client($config['url'], $config['user'], $config['pass'], $debug);
+$repo = $client->getRepo($argv[1], $argv[2]);
diff --git a/src/test.php b/src/test.php
index 3792eb2..0054e05 100755
--- a/src/test.php
+++ b/src/test.php
@@ -2,22 +2,22 @@
getLabelByName('Test')){
- $label=$repo->createLabel(['name'=>'Test','color'=>'#336699']);
+if (!$label = $repo->getLabelByName('Test')) {
+ $label = $repo->createLabel(['name' => 'Test', 'color' => '#336699']);
}
//create a test issue
-$issue=$repo->createIssue([
- 'title'=>'Test',
- 'body'=>'Just testing'
+$issue = $repo->createIssue([
+ 'title' => 'Test',
+ 'body' => 'Just testing',
]);
$issue->addLabel($label);
$issue->addComment('Test comment');
$issue->save();
//change the issue body
-$issue->body.=' (Edited!)';
+$issue->body .= ' (Edited!)';
$issue->save();
diff --git a/src/time_report.php b/src/time_report.php
index e8d335a..4d8cf0d 100755
--- a/src/time_report.php
+++ b/src/time_report.php
@@ -1,58 +1,59 @@
#!/usr/bin/php
getIssues() as $issue){
- $issueNumbers[$issue->id]=$issue->number;
+foreach ($repo->getIssues() as $issue) {
+ $issueNumbers[$issue->id] = $issue->number;
}
-foreach($repo->getPulls() as $pull){
- $issue=$repo->getIssue($pull->number);
- $issueNumbers[$issue->id]=$issue->number;
+foreach ($repo->getPulls() as $pull) {
+ $issue = $repo->getIssue($pull->number);
+ $issueNumbers[$issue->id] = $issue->number;
}
-foreach($repo->getIssues(['state'=>'closed']) as $issue){
- $issueNumbers[$issue->id]=$issue->number;
+foreach ($repo->getIssues(['state' => 'closed']) as $issue) {
+ $issueNumbers[$issue->id] = $issue->number;
}
-foreach($repo->getPulls(['state'=>'closed']) as $pull){
- $issue=$repo->getIssue($pull->number);
- $issueNumbers[$issue->id]=$issue->number;
+foreach ($repo->getPulls(['state' => 'closed']) as $pull) {
+ $issue = $repo->getIssue($pull->number);
+ $issueNumbers[$issue->id] = $issue->number;
}
-$name='jhodges';
-$date='2019-10';
+$name = 'jhodges';
+$date = '2019-10';
-$sums=[];
-foreach($repo->getTimesByUsername($name) as $time){
- if($date==date('Y-m',strtotime($time->created))){
- $number=$issueNumbers[$time->issue_id];
- if(!isset($sums[$number])){
- $issue=$repo->getIssue($number);
- $sums[$number]=[
- 'id'=>$number,
- 'name'=>$issue->title,
- 'time'=>0
- ];
+$sums = [];
+foreach ($repo->getTimesByUsername($name) as $time) {
+ if ($date == date('Y-m', strtotime($time->created))) {
+ $number = $issueNumbers[$time->issue_id];
+ if (!isset($sums[$number])) {
+ $issue = $repo->getIssue($number);
+ $sums[$number] = [
+ 'id' => $number,
+ 'name' => $issue->title,
+ 'time' => 0,
+ ];
+ }
+ $sums[$number]['time'] += $time->time;
}
- $sums[$number]['time']+=$time->time;
- }
}
-function format_time($t){
- return sprintf('%02d:%02d:%02d', floor($t/3600), ($t/60)%60, $t%60);
+function format_time($t)
+{
+ return sprintf('%02d:%02d:%02d', floor($t / 3600), ($t / 60) % 60, $t % 60);
}
-$f=fopen('report.csv','w');
-fputcsv($f,['id','title','time']);
-foreach($sums as $id=>$data){
- $data['time']=format_time($data['time']);
- fputcsv($f,$data);
+$f = fopen('report.csv', 'w');
+fputcsv($f, ['id', 'title', 'time']);
+foreach ($sums as $id => $data) {
+ $data['time'] = format_time($data['time']);
+ fputcsv($f, $data);
}
fclose($f);
echo "Saved as report.csv\n";