File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -392,17 +392,39 @@ async function findInboxIssues() {
392392}
393393
394394function isManagedInboxIssue ( issue ) {
395+ return isLabeledInboxIssue ( issue ) || isMigratableInboxIssue ( issue ) ;
396+ }
397+
398+ function isLabeledInboxIssue ( issue ) {
399+ return hasInboxIdentity ( issue ) && issue . labels ?. some ( ( label ) => label . name === inboxIssueLabel ) ;
400+ }
401+
402+ function isMigratableInboxIssue ( issue ) {
403+ return hasInboxIdentity ( issue ) && isTrustedInboxIssueCreator ( issue ) ;
404+ }
405+
406+ function hasInboxIdentity ( issue ) {
395407 return issue . title === inboxIssueTitle && issue . body ?. includes ( inboxMarker ) ;
396408}
397409
410+ function isTrustedInboxIssueCreator ( issue ) {
411+ return [ "app/github-actions" , "github-actions[bot]" ] . includes ( issue . user ?. login ) ;
412+ }
413+
398414function chooseCanonicalInboxIssue ( issues ) {
415+ const openIssues = issues . filter ( ( issue ) => issue . state === "open" ) ;
416+
399417 return (
400- issues
401- . filter ( ( issue ) => issue . state === "open" )
402- . sort ( ( left , right ) => new Date ( right . updated_at ) - new Date ( left . updated_at ) ) [ 0 ] ?? null
418+ sortIssuesByUpdatedDesc ( openIssues . filter ( isLabeledInboxIssue ) ) [ 0 ] ??
419+ sortIssuesByUpdatedDesc ( openIssues . filter ( isMigratableInboxIssue ) ) [ 0 ] ??
420+ null
403421 ) ;
404422}
405423
424+ function sortIssuesByUpdatedDesc ( issues ) {
425+ return [ ...issues ] . sort ( ( left , right ) => new Date ( right . updated_at ) - new Date ( left . updated_at ) ) ;
426+ }
427+
406428async function closeDuplicateInboxIssues ( issues , canonicalIssue ) {
407429 const closedDuplicateNumbers = [ ] ;
408430
You can’t perform that action at this time.
0 commit comments