diff --git a/src/oca_github_bot/manifest.py b/src/oca_github_bot/manifest.py index 0430659c..ca606bbe 100644 --- a/src/oca_github_bot/manifest.py +++ b/src/oca_github_bot/manifest.py @@ -97,14 +97,19 @@ def set_manifest_version(addon_dir, version): f.write(manifest) +def _is_listed_maintainer(username, manifest): + """Whether username is in the manifest's maintainers, ignoring case.""" + maintainers = {m.lower() for m in manifest.get("maintainers", [])} + return username.lower() in maintainers + + def is_maintainer(username, addon_dirs): for addon_dir in addon_dirs: try: manifest = get_manifest(addon_dir) except NoManifestFound: return False - maintainers = manifest.get("maintainers", []) - if username not in maintainers: + if not _is_listed_maintainer(username, manifest): return False return True @@ -302,7 +307,7 @@ def is_maintainer_other_branches(gh_repo, username, modified_addons, other_branc "__openerp__.py" if float(branch) < 10.0 else "__manifest__.py" ) manifest = _get_manifest_from_api(gh_repo, addon, branch, manifest_file) - if manifest and username in manifest.get("maintainers", []): + if manifest and _is_listed_maintainer(username, manifest): is_maintainer = True break diff --git a/src/oca_github_bot/tasks/mention_maintainer.py b/src/oca_github_bot/tasks/mention_maintainer.py index 4b4649e1..4657ed88 100644 --- a/src/oca_github_bot/tasks/mention_maintainer.py +++ b/src/oca_github_bot/tasks/mention_maintainer.py @@ -50,7 +50,9 @@ def mention_maintainer(org, repo, pr, dry_run=False): if modified_addon_dirs and not modified_addons_maintainers: all_mentions_comment = get_adopt_mention(pr_opener) else: - modified_addons_maintainers.discard(pr_opener) + modified_addons_maintainers = { + m for m in modified_addons_maintainers if m.lower() != pr_opener.lower() + } all_mentions_comment = get_mention(modified_addons_maintainers) if not all_mentions_comment: diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 5f8e9c80..bbce43a8 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -236,6 +236,7 @@ def test_is_maintainer(tmp_path): addon3.mkdir() (addon3 / "__manifest__.py").write_text("{'name': 'addon3'}") assert is_maintainer("u1", [addon1]) + assert is_maintainer("U1", [addon1]) assert not is_maintainer("u1", [addon2]) assert not is_maintainer("u1", [addon1, addon2]) assert is_maintainer("u2", [addon1, addon2]) @@ -261,6 +262,9 @@ def _file_contents(path, ref=None): assert is_maintainer_other_branches( gh_repo_mock, "sbidoul", {"mis_builder"}, ["12.0"] ) + assert is_maintainer_other_branches( + gh_repo_mock, "SBidoul", {"mis_builder"}, ["12.0"] + ) assert not is_maintainer_other_branches( gh_repo_mock, "fpdoo", {"mis_builder"}, ["12.0"] ) diff --git a/tests/test_mention_maintainer.py b/tests/test_mention_maintainer.py index ddf93661..24441a26 100644 --- a/tests/test_mention_maintainer.py +++ b/tests/test_mention_maintainer.py @@ -89,17 +89,17 @@ def test_multi_maintainer_one_mention(git_clone, mocker): @pytest.mark.vcr() -def test_pr_by_maintainer_no_mention(git_clone, mocker): - themaintainer = "themaintainer" +@pytest.mark.parametrize("pr_opener", ["themaintainer", "TheMaintainer"]) +def test_pr_by_maintainer_no_mention(git_clone, mocker, pr_opener): github_mock = mocker.patch("oca_github_bot.tasks.mention_maintainer.github") github_mock.temporary_clone.return_value.__enter__.return_value = str(git_clone) pr_mock = github_mock.login.return_value.__enter__.return_value.pull_request - pr_mock.return_value.user.login = themaintainer + pr_mock.return_value.user.login = pr_opener addon_dirs = list() addon_names = ["addon1", "addon2"] for addon_name in addon_names: - addon_dir = make_addon(git_clone, addon_name, maintainers=[themaintainer]) + addon_dir = make_addon(git_clone, addon_name, maintainers=["themaintainer"]) addon_dirs.append(addon_dir) modified_addons_mock = mocker.patch(