add edit example
This commit is contained in:
parent
9ef8c746a7
commit
5002e79e29
31
src/edit.php
Executable file
31
src/edit.php
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/*******************************************************
|
||||
* This will loop through all issues and add some custom
|
||||
* text to the issue body. It will use a placeholder so
|
||||
* that it can be automatically updated without replacing
|
||||
* the whole issue body
|
||||
********************************************************/
|
||||
|
||||
// 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');
|
||||
|
||||
//this is the function to generate the custom text
|
||||
$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,'<!--BOT-->')===false ){
|
||||
$issue->body.='<hr/><!--BOT--><!--ENDBOT-->';
|
||||
}
|
||||
//replace the tag contents with the result from our $text function
|
||||
$issue->body=preg_replace("#<!--BOT-->.*?<!--ENDBOT-->#s",'<!--BOT-->'.$text($issue).'<!--ENDBOT-->',$issue->body);
|
||||
$issue->save();
|
||||
};
|
||||
|
||||
//process ALL issues
|
||||
$repo->forIssues($tmp);
|
Loading…
Reference in New Issue
Block a user