Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
a2c44392b2 | |||
44344b6f23 | |||
3ed592ce38 | |||
|
238ce05f9a | ||
|
927e68f71b | ||
|
fe713f6926 |
@@ -3,10 +3,16 @@ Simple PHP library to interface with Gitea API
|
||||
|
||||
Designed to make a "Bot" for manipulating labels and issues.
|
||||
|
||||
For usage examples see https://git.jhodges.co.uk/james/GiteaBot-examples
|
||||
For usage examples see https://git.jhodges.co.uk/jhodges/GiteaBot-examples
|
||||
|
||||
## Change Log
|
||||
|
||||
V1.2.1
|
||||
|
||||
* Fixed #1 Added Repo::GetIssues()
|
||||
* Fixed #2 Only POST changed data on save
|
||||
* Updated docs
|
||||
|
||||
v1.2
|
||||
|
||||
* Added namespacing and composer.json
|
||||
|
@@ -4,16 +4,19 @@ namespace JHodges\GiteaBot;
|
||||
class GiteaData{
|
||||
|
||||
protected $data=null;
|
||||
protected $newData=null;
|
||||
|
||||
public function __construct($data=null){
|
||||
$this->newData=new \stdClass();
|
||||
if(!$data){
|
||||
$data=new stdClass();
|
||||
$data=new \stdClass();
|
||||
}
|
||||
$this->data=$data;
|
||||
}
|
||||
|
||||
public function __set($k,$v){
|
||||
$this->data->$k=$v;
|
||||
$this->newData->$k=$v;
|
||||
}
|
||||
|
||||
public function __get($k){
|
||||
|
@@ -15,7 +15,7 @@ class GiteaRepoData extends GiteaData{
|
||||
}
|
||||
|
||||
public function save(){
|
||||
return $this->repo->request($this->url,'PATCH',$this->data);
|
||||
return $this->repo->request($this->url,'PATCH',$this->newData);
|
||||
}
|
||||
|
||||
}
|
||||
|
19
src/Repo.php
19
src/Repo.php
@@ -32,6 +32,25 @@ class Repo{
|
||||
}
|
||||
}
|
||||
|
||||
public function getIssues($args=null){
|
||||
$page=1;
|
||||
$all_issues=[];
|
||||
while(1){
|
||||
$url="repos/{$this->user}/{$this->repo}/issues?page=$page";
|
||||
if($args){
|
||||
$url.='&'.http_build_query($args);
|
||||
}
|
||||
$issues=$this->client->request($url);
|
||||
foreach($issues as $data){
|
||||
$issue=new Issue($this,$data);
|
||||
$all_issues[]=$issue;
|
||||
}
|
||||
if(!$issues) break;
|
||||
$page++;
|
||||
}
|
||||
return $all_issues;
|
||||
}
|
||||
|
||||
public function getLabelByName($name){
|
||||
$url="repos/{$this->user}/{$this->repo}/labels";
|
||||
if(!isset($this->cache['lables'])){
|
||||
|
Reference in New Issue
Block a user