From 6123f69996ee33d60eafe12396cc437a45dfe1df Mon Sep 17 00:00:00 2001 From: James Date: Fri, 16 Aug 2019 16:42:24 +0100 Subject: [PATCH] fix examples and move into a dir of their own --- .../no_label_milestone.php | 4 +- repeat.php => example/repeat.php | 4 +- import.csv => example/test.csv | 0 example/test.php | 28 +++++++++++ import.php | 48 ------------------- 5 files changed, 32 insertions(+), 52 deletions(-) rename no_label_milestone.php => example/no_label_milestone.php (95%) rename repeat.php => example/repeat.php (97%) rename import.csv => example/test.csv (100%) create mode 100644 example/test.php delete mode 100644 import.php diff --git a/no_label_milestone.php b/example/no_label_milestone.php similarity index 95% rename from no_label_milestone.php rename to example/no_label_milestone.php index b6865b6..211585e 100644 --- a/no_label_milestone.php +++ b/example/no_label_milestone.php @@ -4,9 +4,9 @@ //2a. Adds a no-label label to any issues with no labels (excluding the no-label and no-milestone) //2b. Also removes the label if present on an issue with a label (excluding the no-label and no-milestone) -require('bootstrap.php'); +require(__DIR__.'/../bootstrap.php'); -$config=require('config.php'); +$config=require(__DIR__.'/../config.php'); //pass cmd line args if($argc<3){ diff --git a/repeat.php b/example/repeat.php similarity index 97% rename from repeat.php rename to example/repeat.php index 6aaf676..6582cdc 100644 --- a/repeat.php +++ b/example/repeat.php @@ -1,7 +1,7 @@ [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]); + +//create a label +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->addLabel($label); +$issue->addComment('Test comment'); +$issue->save(); diff --git a/import.php b/import.php deleted file mode 100644 index 13fa3b7..0000000 --- a/import.php +++ /dev/null @@ -1,48 +0,0 @@ - [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]); - -function label($name){ - if($label=$repo->getLabelByName($name)){ - return $label; - }else{ - return $repo->createLabel($name); - } -} - -function issue($name){ - if($label=$repo->getIssueByName($name)){ - return $issue; - }else{ - return $repo->createIssue($name); - } -} - -/* -$jan=label('janurary/repeat'); -$iss=issue('test'); -$iss->addLabel($jan); -*/ - -/* -//do the import -$f=fopen('import.csv','r'); -while($data=fgetcsv($f)){ - print_r($data); -} -*/ - -$issue=new Issue($repo); -$issue->setTitle('nice')->setBody('ly')->save(); -print_r($issue);