Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
"""Author identity across forges: noreply folding and automation accounts."""
from __future__ import annotations
import pytest
from repowise.core.forges import (
ForgeKind,
all_forges,
canonical_email,
is_bot,
noreply_login,
normalize_identity,
)
GH, GL = ForgeKind.GITHUB, ForgeKind.GITLAB
@pytest.mark.parametrize(
("email", "name", "canonical", "bot"),
[
# GitHub: both noreply forms fold to the id-less one.
("[email protected]", "Octo Cat", "[email protected]", False),
("[email protected]", "Octo", "[email protected]", False),
("[email protected]", "o", "[email protected]", False),
(" [email protected] ", "Dev", "[email protected]", False),
("49699333+dependabot[bot]@users.noreply.github.com", "dependabot[bot]",
"dependabot[bot]@users.noreply.github.com", True),
("[email protected]", "GitHub Actions", "[email protected]", True),
("[email protected]", "GitHub", "[email protected]", True),
("[email protected]", "github-actions", "[email protected]", True),
("[email protected]", "Some App", "[email protected]", True),
# GitLab: the id is always there, so the address is kept as is.
("[email protected]", "Jane Doe",
"[email protected]", False),
("[email protected]", "Jane", "[email protected]", False),
("[email protected]", "deploy token",
"[email protected]", True),
("[email protected]", "group_7_bot", "[email protected]", True),
("[email protected]", "GitLab Bot", "[email protected]", True),
("[email protected]", "Ghost User", "[email protected]", True),
("[email protected]", "ghost", "[email protected]", False),
("[email protected]", "Pat", "[email protected]", False),
# Azure DevOps
("[email protected]", "Project Collection Build Service (contoso)", "[email protected]", True),
("[email protected]", "Fabrikam Build Service (contoso)", "[email protected]", True),
("", "azure-pipelines", "", True),
("", "azure-pipelines[bot]", "", True),
("[email protected]", "Build Service", "[email protected]", False),
# Bitbucket
("[email protected]", "bitbucket-pipelines",
"[email protected]", True),
("[email protected]", "Jane Doe", "[email protected]", True),
# People stay people.
("[email protected]", "Dev", "[email protected]", False),
("[email protected]", "Netlify Johnson", "[email protected]", False),
("[email protected]", "Abbot", "[email protected]", False),
("", "", "", False),
],
)
def test_normalize_identity(email: str, name: str, canonical: str, bot: bool) -> None:
assert normalize_identity(email, name) == (canonical, bot)
# An address keeps its minting forge's shape, so every forge reads it alike.
for forge in all_forges():
assert forge.normalize_identity(email, name) == (canonical, bot)
@pytest.mark.parametrize(
"name",
[
"dependabot", "renovate", "renovatebot", "greenkeeper", "snyk", "snyk-bot", "imgbot",
"github-actions", "GitHub Actions", "semantic-release", "allcontributors", "codecov",
"mergify", "pre-commit-ci", "netlify", "vercel", "bot", "release-bot", "ci_bot",
"renovate[bot]",
],
)
def test_forge_neutral_bot_names(name: str) -> None:
assert is_bot(name, "")
@pytest.mark.parametrize(
("email", "login"),
[
("[email protected]", (GH, "octo")),
("[email protected]", (GH, "octo")),
("[email protected]", (GL, "jdoe")),
("[email protected]", (GL, "a-b")),
("[email protected]", None), # GitLab always writes the id
("[email protected]", None),
("[email protected]", None),
("[email protected]", None),
("", None),
],
)
def test_noreply_login(email: str, login: tuple[ForgeKind, str] | None) -> None:
assert noreply_login(email) == login
def test_canonical_email_handles_none() -> None:
assert canonical_email(None) == ""