add keep functionality to stale bot
This commit is contained in:
parent
46bdc40819
commit
ca9933f729
@ -2,11 +2,12 @@
|
||||
<?php
|
||||
/*
|
||||
1. loop through all issues:
|
||||
2. if issue has stale "label":
|
||||
2.1. if activity since label was added then remove label
|
||||
2.2. if still no activity in 7 days then close
|
||||
3. if issue doesn not has stale "label"
|
||||
3.1. if no activity in >30 dyas then add "stale" label
|
||||
3. if issue has "keep" label then skip it
|
||||
3. if issue has stale "label":
|
||||
3.1. if activity since label was added then remove label
|
||||
3.2. if still no activity in 7 days then close
|
||||
4. if issue doesn not has stale "label"
|
||||
4.1. if no activity in >30 dyas then add "stale" label
|
||||
*/
|
||||
|
||||
// load the config, create the connection and load the repo sepcified on the cmd line args
|
||||
@ -17,13 +18,18 @@ require 'setup.php';
|
||||
if (!$staleLabel = $repo->getLabelByName('stale')) {
|
||||
$staleLabel = $repo->createLabel(['name' => 'stale', 'color' => '#fad8c7']);
|
||||
}
|
||||
if (!$keepLabel = $repo->getLabelByName('keep')) {
|
||||
$keepLabel = $repo->createLabel(['name' => 'keep', 'color' => '#bfe5bf']);
|
||||
}
|
||||
|
||||
//define the function to process each issue
|
||||
$callback = function($issue) use ($staleLabel) {
|
||||
$updatedTime=strtotime($issue->updated_at);
|
||||
$updateDaysAgo=(time()-$updatedTime)/60/60/24;
|
||||
echo "#{$issue->number} - $updateDaysAgo days ago - {$issue->title}\n";
|
||||
if($issue->hasLabel($staleLabel)){
|
||||
if($issue->hasLabel($keepLabel)){
|
||||
return;
|
||||
}elseif($issue->hasLabel($staleLabel)){
|
||||
//when was it added?
|
||||
$staleTime=null;
|
||||
foreach($issue->getComments() as $comment){
|
||||
|
Loading…
Reference in New Issue
Block a user