mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-03 10:37:46 +09:00
* fix(hooks): check staged blobs and fail closed in the changelog tools The pre-commit hooks read working-tree files while claiming to check staged content, check-changelog.py passed when its base diff failed, and fold-changelog.py deleted fragments it had not validated. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(tests): make CI helper scripts fail when they check nothing check_all_pages.sh passed without logging in or crawling, the sink inventory accepted ripgrep errors, install_packages.sh and copyright_year.sh lost their failures, and the LDAP spec asserted before navigation finished. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix(i18n): audit only changed .po entries and keep contributor badges separate audit_po.py failed every translation PR on pre-existing errors and matched non-printf text as conversions; update-contributors.py leaked badges between aliased contributors. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs(changelog): add fragment for #8457 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test(e2e): move the pointer off the Deepness multiselect button Deepness sets a zero body margin, so the unhovered #ms-button sits at the viewport origin and headless Chromium on Linux intermittently applies :hover to it. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci: pull pinned integration database from authenticated mirror Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
"""Keep contributor badge refreshes from leaking or dropping badges.
|
|
|
|
Copyright (C) 2004-2026 The Cacti Group. GPL-2.0-or-later.
|
|
"""
|
|
import importlib.util
|
|
import json
|
|
from pathlib import Path
|
|
import unittest
|
|
from unittest import mock
|
|
|
|
SCRIPT = Path(__file__).resolve().parents[2] / '.github/scripts/update-contributors.py'
|
|
SPEC = importlib.util.spec_from_file_location('update_contributors', SCRIPT)
|
|
TOOL = importlib.util.module_from_spec(SPEC)
|
|
SPEC.loader.exec_module(TOOL)
|
|
|
|
|
|
def bucket(*paths):
|
|
return {'emails': set(), 'paths': set(paths), 'messages': ['change']}
|
|
|
|
|
|
class AliasMergeTest(unittest.TestCase):
|
|
def test_alias_merge_does_not_leak_into_shared_author_buckets(self):
|
|
alice = bucket('lib/functions.php')
|
|
by_author = {'alice': alice, 'alice@example.com': alice,
|
|
'alice smith': bucket('tests/Unit/FooTest.php')}
|
|
config = {'contributors': [
|
|
{'login': 'alice', 'name': 'alice', 'contributions': ['code']},
|
|
{'login': 'bob', 'name': 'bob', 'contributions': ['code']},
|
|
]}
|
|
aliases = {'alice': ['Alice Smith'], 'bob': ['alice@example.com']}
|
|
with mock.patch.object(TOOL, 'git_log_by_author', return_value=by_author), \
|
|
mock.patch.object(TOOL, 'FOUNDER_ALIASES', aliases):
|
|
self.assertTrue(TOOL.refresh_path_badges(config))
|
|
self.assertEqual(config['contributors'][0]['contributions'], ['code', 'test'])
|
|
self.assertEqual(config['contributors'][1]['contributions'], ['code'])
|
|
self.assertEqual(alice['paths'], {'lib/functions.php'})
|
|
|
|
|
|
class BadgeOrderTest(unittest.TestCase):
|
|
def test_badge_types_outside_badge_order_are_kept(self):
|
|
self.assertEqual(TOOL.ordered_badges(['video', 'code'], {'video', 'code', 'review'}),
|
|
['code', 'review', 'video'])
|
|
|
|
def test_review_refresh_keeps_curated_badges(self):
|
|
config = {'contributors': [{'login': 'carol', 'contributions': ['code', 'video']}]}
|
|
page = {'data': {'repository': {'pullRequests': {
|
|
'pageInfo': {'hasNextPage': False, 'endCursor': None},
|
|
'nodes': [{'reviews': {'nodes': [{'author': {'login': 'Carol'}}]}}],
|
|
}}}}
|
|
with mock.patch.object(TOOL, 'run', return_value=json.dumps(page)):
|
|
self.assertTrue(TOOL.refresh_review_badges(config))
|
|
self.assertEqual(config['contributors'][0]['contributions'], ['code', 'review', 'video'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|