@@ -334,6 +334,7 @@ async def find_github_identity(github_username: str):
334334 WHERE
335335 platform = 'github'
336336 AND value = $1
337+ AND "verified" = TRUE
337338 AND "deletedAt" is null
338339 LIMIT 1
339340 """
@@ -405,18 +406,45 @@ async def update_maintainer_run(repo_id: str, maintainer_file: str):
405406
406407
407408async def get_maintainers_for_repo (repo_id : str ):
409+ # Active rows only (endDate IS NULL) — reappearing maintainers hit the "new"
410+ # branch and get reactivated by upsert_maintainer's ON CONFLICT clause.
411+ # verified=TRUE mirrors find_github_identity / find_maintainer_identity_by_email.
412+ # platform/type are returned so the diff's safety guard can match identifiers
413+ # by kind and avoid cross-platform value collisions (e.g. a GitHub username
414+ # "foo" colliding with a same-named handle on another platform).
408415 maintainers_sql_query = """
409- SELECT mi.role, mi."originalRole", mi."repoUrl", mi."repoId", mi."identityId", mem.value as github_username
416+ SELECT mi.role, mi."originalRole", mi."repoUrl", mi."repoId", mi."identityId",
417+ mem.value as identity_value, mem.platform, mem.type
410418 FROM "maintainersInternal" mi
411419 JOIN "memberIdentities" mem ON mi."identityId" = mem.id
412- WHERE mi."repoId" = $1 AND mem.platform = 'github' AND mem.type = 'username' and mem.verified = True AND mem."deletedAt" is null
420+ WHERE mi."repoId" = $1
421+ AND mi."endDate" IS NULL
422+ AND mem."verified" = TRUE
423+ AND mem."deletedAt" is null
413424 """
414425 return await query (
415426 maintainers_sql_query ,
416427 (repo_id ,),
417428 )
418429
419430
431+ async def get_github_maintainer_usernames_for_repo (repo_id : str ) -> set [str ]:
432+ """Return GitHub usernames of active maintainers for fork/parent-repo filtering."""
433+ sql_query = """
434+ SELECT mem.value
435+ FROM "maintainersInternal" mi
436+ JOIN "memberIdentities" mem ON mi."identityId" = mem.id
437+ WHERE mi."repoId" = $1
438+ AND mi."endDate" IS NULL
439+ AND mem.platform = 'github'
440+ AND mem.type = 'username'
441+ AND mem."verified" = TRUE
442+ AND mem."deletedAt" is null
443+ """
444+ rows = await query (sql_query , (repo_id ,))
445+ return {row ["value" ] for row in rows }
446+
447+
420448async def set_maintainer_end_date (
421449 repo_id : str , identity_id : str , role : str , change_date : datetime
422450):
0 commit comments