11# Copyright (c) Microsoft. All rights reserved.
22
3- """Scan open issues and PRs for stale follow-ups from external authors .
3+ """Scan open issues and PRs labeled 'waiting- for-author' for stale follow-ups.
44
5- If a team member commented and the external author hasn't replied within
6- DAYS_THRESHOLD days, post a reminder comment and add the 'needs-info' label.
5+ Team members manually add the 'waiting-for-author' label when they need a
6+ response from the external author. If the author hasn't replied within
7+ DAYS_THRESHOLD days of the last team comment, post a reminder and add the
8+ 'requested-info' label to prevent duplicate pings.
79"""
810
911from __future__ import annotations
2224 "@{author}, friendly reminder — this issue is waiting on your response. "
2325 "Please share any updates when you get a chance. (This is an automated message.)"
2426)
25- LABEL = "needs-info"
27+ TRIGGER_LABEL = "waiting-for-author"
28+ PINGED_LABEL = "requested-info"
2629
2730
2831def get_team_members (g : Github , org : str , team_slug : str ) -> set [str ]:
@@ -76,15 +79,21 @@ def should_ping(
7679 days_threshold : int ,
7780 now : datetime ,
7881) -> bool :
79- """Determine whether this issue/PR should be pinged."""
82+ """Determine whether this issue/PR should be pinged.
83+
84+ Only issues/PRs carrying the 'waiting-for-author' label are candidates.
85+ """
8086 author = issue .user .login
8187
88+ # Skip if the trigger label is not present
89+ if not any (label .name == TRIGGER_LABEL for label in issue .labels ):
90+ return False
8291 # Skip if author is a team member
8392 if author in team_members :
8493 return False
8594
86- # Skip if already labeled
87- if any (label .name == LABEL for label in issue .labels ):
95+ # Skip if already pinged
96+ if any (label .name == PINGED_LABEL for label in issue .labels ):
8897 return False
8998
9099 # Skip if no comments at all
@@ -112,7 +121,7 @@ def should_ping(
112121
113122
114123def ping (issue : Issue , dry_run : bool ) -> bool :
115- """Post a reminder comment and add the needs -info label. Returns True on success."""
124+ """Post a reminder comment and add the 'requested -info' label. Returns True on success."""
116125 author = issue .user .login
117126 kind = "PR" if issue .pull_request else "Issue"
118127
@@ -129,7 +138,7 @@ def ping(issue: Issue, dry_run: bool) -> bool:
129138 issue .create_comment (PING_COMMENT .format (author = author ))
130139 commented = True
131140 if not labeled :
132- issue .add_to_labels (LABEL )
141+ issue .add_to_labels (PINGED_LABEL )
133142 labeled = True
134143 print (f" Pinged { kind } #{ issue .number } (@{ author } )" )
135144 return True
@@ -184,9 +193,9 @@ def main() -> None:
184193 failed = []
185194 scanned = 0
186195
187- print (f"Scanning open issues and PRs (threshold: { days_threshold } days)...\n " )
196+ print (f"Scanning open issues and PRs labeled ' { TRIGGER_LABEL } ' (threshold: { days_threshold } days)...\n " )
188197
189- for issue in repo .get_issues (state = "open" ):
198+ for issue in repo .get_issues (state = "open" , labels = [ TRIGGER_LABEL ] ):
190199 scanned += 1
191200
192201 if should_ping (issue , team_members , days_threshold , now ):
0 commit comments