refactor for the new lib structure

This commit is contained in:
Bob 2019-08-26 10:07:14 +01:00
parent 41ff24e0ab
commit e54c149df4
8 changed files with 53 additions and 69 deletions

View File

@ -1,14 +1,14 @@
{
"name": "acme/bot",
"description": "my bot!",
"name": "jhodges/giteabot-examples",
"description": "Some examples for the giteabot php api",
"authors": [
{
"name": "Me",
"email": "me@example.com"
"name": "James",
"email": "inbox.dev@jhodges.co.uk"
}
],
"require": {
"jh/giteabot": "dev-composer"
"jhodges/giteabot": "dev-develop"
},
"repositories": {
"repo-name": {

19
composer.lock generated
View File

@ -4,19 +4,24 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e4333e0eb4df20a9093b9e14e4ac3536",
"content-hash": "b3bb2bfb9afd1fce021dcecb79442c77",
"packages": [
{
"name": "jh/giteabot",
"version": "dev-composer",
"name": "jhodges/giteabot",
"version": "dev-develop",
"source": {
"type": "git",
"url": "https://git.jhodges.co.uk/james/GiteaBot",
"reference": "d6ca95922617f25903dda431d9ed695c7a270ae4"
"reference": "d5c65bcb7e84d09ecdb6f6c084c4438104231099"
},
"type": "library",
"autoload": {
"psr-4": {
"JHodges\\GiteaBot\\": "src/"
}
},
"license": [
"OS"
"GPL3"
],
"authors": [
{
@ -25,14 +30,14 @@
}
],
"description": "Simple PHP library to interface with Gitea API",
"time": "2019-08-24T13:52:48+00:00"
"time": "2019-08-26T08:51:06+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"jh/giteabot": 20
"jhodges/giteabot": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View File

@ -1,17 +1,7 @@
<?php
require(__DIR__.'/../vendor/autoload.php');
$config=require(__DIR__.'/config.php');
//pass cmd line args
if($argc<3){
die(basename(__FILE__)." <USER> <REPO> [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]);
// load the config, create the connection and load the repo sepcified on the cmd line args
// we will then have $client and $repo available
require('setup.php');
//close all issues
$repo->forIssues(function($issue){

View File

@ -1,22 +1,14 @@
<?php
//1a. Adds a no-milestone label to any issues with no milestone
//1b. Also removes the label if present on an issue with a milestone
//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)
/*****
** 1a. Adds a no-milestone label to any issues with no milestone
** 1b. Also removes the label if present on an issue with a milestone
** 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(__DIR__.'/../vendor/autoload.php');
$config=require(__DIR__.'/config.php');
//pass cmd line args
if($argc<3){
die(basename(__FILE__)." <USER> <REPO> [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]);
// load the config, create the connection and load the repo sepcified on the cmd line args
// we will then have $client and $repo available
require('setup.php');
//get the labels of interest
$nolabelLabel=$repo->getLabelByName('no-label');

View File

@ -1,18 +1,9 @@
<?php
require(__DIR__.'/../vendor/autoload.php');
$config=require(__DIR__.'/config.php');
//pass cmd line args
if($argc<3){
die(basename(__FILE__)." <USER> <REPO> [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]);
// load the config, create the connection and load the repo sepcified on the cmd line args
// we will then have $client and $repo available
require('setup.php');
//define the repeat terms
$terms=[
'months'=>['janurary','feburary','march','april','may','june','july','august','september','october','november','december'],
'days'=>['monday','tuesday','wednesday','thursday','friday','saturday','sunday'],

17
src/setup.php Normal file
View File

@ -0,0 +1,17 @@
<?php
require(__DIR__.'/../vendor/autoload.php');
use JHodges\GiteaBot\Client;
$config=require(__DIR__.'/config.php');
//pass cmd line args
if($argc<3){
die(basename(__FILE__)." <USER> <REPO> [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]);

View File

@ -1 +0,0 @@
"example title","example body","test"
1 example title example body test

View File

@ -1,17 +1,7 @@
<?php
require(__DIR__.'/../vendor/autoload.php');
$config=require(__DIR__.'/config.php');
//pass cmd line args
if($argc<3){
die(basename(__FILE__)." <USER> <REPO> [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]);
// load the config, create the connection and load the repo sepcified on the cmd line args
// we will then have $client and $repo available
require('setup.php');
//get the test label or create if not exist
if(!$label=$repo->getLabelByName('Test')){