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