Skip to content

Commit 8dc31d3

Browse files
committed
fix: preserve registry branches during scans
1 parent e13d5b9 commit 8dc31d3

2 files changed

Lines changed: 72 additions & 7 deletions

File tree

.github/scripts/scan_github_plugins.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,16 @@ def main():
370370
remove_registry_entry(registry, update_times, platform_metadata, key, skip_reason)
371371
stats["removed"] += 1
372372
else:
373-
# Update metadata
373+
# Update metadata. Registry branches are curated and must not
374+
# follow repository default-branch changes automatically.
374375
updated_desc = info.get('description') or data[2]
375-
updated_branch = info.get('default_branch') or data[3]
376+
registry_branch = data[3]
376377
updated_at = info.get('pushed_at') or info.get('updated_at')
377378
current_platforms = get_registry_entry_platforms(data)
378-
platform_decision = detect_platforms_for_repo(owner, repo_name, updated_branch, info)
379+
platform_decision = detect_platforms_for_repo(owner, repo_name, registry_branch, info)
379380
detected_platforms = decision_platforms(platform_decision)
380381
metadata_entry = platform_metadata["entries"].get(key, {})
381-
if metadata_entry.get("identity") != platform_metadata_identity(owner, repo_name, updated_branch):
382+
if metadata_entry.get("identity") != platform_metadata_identity(owner, repo_name, registry_branch):
382383
metadata_entry = {}
383384
next_platforms, platform_policy = choose_platforms_for_registry(
384385
current_platforms,
@@ -389,7 +390,6 @@ def main():
389390

390391
# Check if changed
391392
if (updated_desc != data[2] or
392-
updated_branch != data[3] or
393393
update_times.get(key) != updated_at or
394394
next_platforms != current_platforms):
395395

@@ -409,7 +409,7 @@ def main():
409409
owner,
410410
repo_name,
411411
updated_desc,
412-
updated_branch,
412+
registry_branch,
413413
next_platforms
414414
)
415415
if updated_at:
@@ -423,7 +423,7 @@ def main():
423423
key,
424424
owner,
425425
repo_name,
426-
updated_branch,
426+
registry_branch,
427427
next_platforms,
428428
decision=platform_decision,
429429
policy_action=platform_policy,

tests/test_registry_scripts.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,71 @@ def test_scanner_updates_existing_registry_platforms(scan_plugins_module, tmp_pa
578578
assert metadata["entries"]["Plugin"]["source"] == "detected"
579579

580580

581+
def test_scanner_never_updates_existing_registry_branch(scan_plugins_module, tmp_path, monkeypatch):
582+
registry_file = tmp_path / "registry.json"
583+
update_times_file = tmp_path / "update_times.json"
584+
metadata_file = tmp_path / "platform_detection.json"
585+
registry_file.write_text(json.dumps({
586+
"Idle": ["Idle", "Idle", "Idle", "master"],
587+
"luxtronikex": [
588+
"Rouzax",
589+
"luxtronik-domoticz-plugin-v2",
590+
"description",
591+
"dist",
592+
"",
593+
["linux", "windows"],
594+
],
595+
}))
596+
update_times_file.write_text(json.dumps({
597+
"luxtronikex": "2026-03-14T14:52:18Z",
598+
}))
599+
600+
repo_info = {
601+
"archived": False,
602+
"disabled": False,
603+
"size": 100,
604+
"full_name": "Rouzax/luxtronik-domoticz-plugin-v2",
605+
"owner": {"login": "Rouzax"},
606+
"name": "luxtronik-domoticz-plugin-v2",
607+
"description": "updated description",
608+
"default_branch": "main",
609+
"pushed_at": "2026-07-02T11:45:18Z",
610+
}
611+
612+
seen_branches = []
613+
614+
def detect_platforms(owner, repo, branch, repo_info=None):
615+
seen_branches.append(branch)
616+
return platform_decision(["linux", "windows"], confidence="high")
617+
618+
patch_scanner_paths(scan_plugins_module, monkeypatch, registry_file, update_times_file, metadata_file)
619+
monkeypatch.setattr(scan_plugins_module, "get_repo_info", lambda owner, repo: repo_info)
620+
monkeypatch.setattr(scan_plugins_module, "search_github", lambda: [])
621+
monkeypatch.setattr(scan_plugins_module, "search_gitlab", lambda: [])
622+
monkeypatch.setattr(scan_plugins_module, "search_codeberg", lambda: [])
623+
monkeypatch.setattr(scan_plugins_module, "detect_platforms_for_repo", detect_platforms)
624+
monkeypatch.setenv("GITHUB_TOKEN", "test-token")
625+
626+
scan_plugins_module.main()
627+
628+
registry = json.loads(registry_file.read_text())
629+
metadata = json.loads(metadata_file.read_text())
630+
631+
assert seen_branches == ["dist"]
632+
assert registry["luxtronikex"] == [
633+
"Rouzax",
634+
"luxtronik-domoticz-plugin-v2",
635+
"updated description",
636+
"dist",
637+
"",
638+
["linux", "windows"],
639+
]
640+
assert metadata["entries"]["luxtronikex"]["branch"] == "dist"
641+
assert metadata["entries"]["luxtronikex"]["identity"] == (
642+
"github.com/rouzax/luxtronik-domoticz-plugin-v2@dist"
643+
)
644+
645+
581646
def test_scanner_adds_platforms_for_new_plugins(scan_plugins_module, tmp_path, monkeypatch):
582647
registry_file = tmp_path / "registry.json"
583648
update_times_file = tmp_path / "update_times.json"

0 commit comments

Comments
 (0)