Skip to content

Commit 9a18eb7

Browse files
committed
fix: prefer email over github and resolve git emails via username identity
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent bb01419 commit 9a18eb7

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

services/apps/git_integration/src/crowdgit/database/crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ async def find_many_member_ids_by_identities(identities: list[dict]) -> list[dic
630630
ON mi.type = i.identity_type
631631
AND mi.verified = i.verified
632632
AND lower(mi.value) = lower(i.value)
633-
AND (i.platform IS NULL OR mi.platform = i.platform)
633+
AND mi.platform = i.platform
634634
AND mi."deletedAt" IS NULL
635635
ORDER BY i.idx
636636
""",

services/apps/git_integration/src/crowdgit/services/affiliation/affiliation_service.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,18 @@ def group_parse_rows(
357357

358358
for row in rows:
359359
raw_contributor = row.contributor
360-
github = cls._strip(raw_contributor.github)
361-
if github:
362-
github = github.lstrip("@").lower()
363360
email = cls._strip(raw_contributor.email)
364361
if email:
365362
email = email.replace("!", "@").lower()
363+
github = cls._strip(raw_contributor.github)
364+
if github:
365+
github = github.lstrip("@").lower()
366366
name = cls._strip(raw_contributor.name)
367367

368-
if github:
369-
contributor_key = ("github", github)
370-
elif email:
368+
if email:
371369
contributor_key = ("email", email)
370+
elif github:
371+
contributor_key = ("github", github)
372372
else:
373373
continue
374374

@@ -584,10 +584,10 @@ def affiliation_stint_key(
584584
contributor: AffiliationContributor, domain: str
585585
) -> tuple[str, str, str] | None:
586586
domain = domain.lower()
587-
if contributor.github:
588-
return ("github", contributor.github.lower(), domain)
589587
if contributor.email:
590588
return ("email", contributor.email.lower(), domain)
589+
if contributor.github:
590+
return ("github", contributor.github.lower(), domain)
591591
return None
592592

593593
async def exclude_parent_repo_affiliations(
@@ -665,23 +665,23 @@ async def apply_affiliations(
665665
for entry in affiliations:
666666
contributor = entry.contributor
667667
member_idx: int | None = None
668-
if contributor.github:
668+
if contributor.email:
669669
member_idx = len(member_identity_inputs)
670670
member_identity_inputs.append(
671671
{
672672
"type": "username",
673-
"platform": "github",
674-
"value": contributor.github,
673+
"platform": "git",
674+
"value": contributor.email,
675675
"verified": True,
676676
}
677677
)
678-
elif contributor.email:
678+
elif contributor.github:
679679
member_idx = len(member_identity_inputs)
680680
member_identity_inputs.append(
681681
{
682-
"type": "email",
683-
"platform": None,
684-
"value": contributor.email,
682+
"type": "username",
683+
"platform": "github",
684+
"value": contributor.github,
685685
"verified": True,
686686
}
687687
)

0 commit comments

Comments
 (0)