From ca9933f72983c7d51393845b330dd19004d94f6c Mon Sep 17 00:00:00 2001 From: James Date: Sat, 17 Oct 2020 11:39:23 +0100 Subject: [PATCH] add keep functionality to stale bot --- src/stale.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/stale.php b/src/stale.php index 28c7e97..6551033 100755 --- a/src/stale.php +++ b/src/stale.php @@ -2,11 +2,12 @@ 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){